Results 1 to 5 of 5

Thread: Use container classes rather than simple arrays?

  1. #1
    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.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    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.

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    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.

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    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.

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    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.

Similar Threads

  1. .mov file container
    By Rufta in forum Windows Software
    Replies: 3
    Last Post: 25-12-2010, 03:27 PM
  2. The list container of the C++
    By BossBattle in forum Software Development
    Replies: 5
    Last Post: 27-02-2010, 08:39 PM
  3. What is Servlet container?
    By Sonam Goenka in forum Software Development
    Replies: 5
    Last Post: 05-02-2010, 08:13 AM
  4. How to create DB2 9.5 container
    By Pollock in forum Windows Software
    Replies: 3
    Last Post: 12-08-2009, 11:57 AM
  5. STL container question
    By JACKOPA in forum Software Development
    Replies: 4
    Last Post: 25-10-2008, 04:24 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,622,233.32703 seconds with 17 queries