Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Use container classes rather than simple arrays?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 02-02-2010
Member
 
Join Date: Sep 2009
Posts: 125
Use container classes rather than simple arrays?
  

I have recently finished studying basics of C++ programming language. Though this was my first programming language I found it to be very easy. As I have completed C++, there is an assignment that I have to work on. One question in the assignments asks explanation as to why container classes are used rather than simple arrays? Provide some of your opinions on this.

Reply With Quote
  #2  
Old 02-02-2010
Member
 
Join Date: May 2008
Posts: 2,007
Re: Use container classes rather than simple arrays?

The main reason why software programmers prefer container classes over simple arrays of C++ is that container classes are considered to be more productive than simple arrays. Another major reason is that a more powerfully built program can be written using container classes instead of the simple arrays.
Reply With Quote
  #3  
Old 02-02-2010
Member
 
Join Date: Oct 2005
Posts: 2,389
Lesser bugs with container classes

By many it is been noted that programs coded in C++ using the container classes are containing lesser number of bugs as compared to programs written using arrays. Also programs written with container classes are more secured. One of the popularly noted problem with arrays is that subscripts of arrays go unchecked and are not tracked down for out of bound arrays.
Reply With Quote
  #4  
Old 02-02-2010
Member
 
Join Date: Feb 2008
Posts: 1,845
Container classes provide easy memory management

The storage of Array elements is done on Heap Memory. There is a pitfall for allocating heap storage which is that you will have to assign a code that will always de-allocate the memory space on heap. The advantage with container classes is that the process of memory management is taken care automatically. Thus to have a more easy memory management it is recommended to use Container classes over arrays.
Reply With Quote
  #5  
Old 02-02-2010
Member
 
Join Date: May 2008
Posts: 2,290
Re: Use container classes rather than simple arrays?

Consider an instance where an element has to be inserted in an array. This element has to inserted in between. And this is not possible in array. But this is feasible with container classes. Another characteristic of container class is that the programmer can choose whether to pass by value or pass by reference. But with arrays this is restricted.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Use container classes rather than simple arrays?"
Thread Thread Starter Forum Replies Last Post
.mov file container Rufta Windows Software 3 25-12-2010 02:27 PM
The list container of the C++ BossBattle Software Development 5 27-02-2010 07:39 PM
What is Servlet container? Sonam Goenka Software Development 5 05-02-2010 07:13 AM
How to create DB2 9.5 container Pollock Windows Software 3 12-08-2009 11:57 AM
STL container question JACKOPA Software Development 4 25-10-2008 04:24 PM


All times are GMT +5.5. The time now is 01:57 AM.