memory leak in the code?

This is a discussion on memory leak in the code? within the C++ Programming forums, part of the General Programming Boards category; I just want to learn in what situations using dynamic allocated array is better than using vector? In my experience, ...

  1. #16
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,717
    I just want to learn in what situations using dynamic allocated array is better than using vector? In my experience, I always think vector is better than dynamic allocated array for a couple of reasons. :-)
    Daved and I agree with you.

    EDIT:
    Consequently, the only situation when using a dynamically allocated array is better than using a vector is when you cannot use a vector for some reason. Such reasons range from the dictates of a professor/teacher or management to the limitations of the compiler that you have to use (which again could be due to the whim of a professor or management).
    Last edited by laserlight; 01-13-2008 at 02:24 AM.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #17
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Agree, laserlight!


    My question is answered.

    Quote Originally Posted by laserlight View Post
    Daved and I agree with you.

    EDIT:
    Consequently, the only situation when using a dynamically allocated array is better than using a vector is when you cannot use a vector for some reason. Such reasons range from the dictates of a professor/teacher or management to the limitations of the compiler that you have to use (which again could be due to the whim of a professor or management).

    regards,
    George

  3. #18
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,604
    I can't think of a specific situation where a dynamically allocated array is better than a vector.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #19
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Agree, Elysia. Vector is invented to replace dynamic array. But in some legacy code, we have to maintain. :-)


    Quote Originally Posted by Elysia View Post
    I can't think of a specific situation where a dynamically allocated array is better than a vector.

    regards,
    George

  5. #20
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,604
    Well, in that case, a dynamic array isn't better, instead we are limited to a dynamic array unless you rewrite that code.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #21
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks Elysia,


    Quote Originally Posted by Elysia View Post
    Well, in that case, a dynamic array isn't better, instead we are limited to a dynamic array unless you rewrite that code.
    Agree. :-)


    regards,
    George

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. memory leak
    By rahulsk1947 in forum C Programming
    Replies: 2
    Last Post: 11-11-2007, 12:27 PM
  2. Memory leak with detached pthreads - how to free?
    By rfk in forum Linux Programming
    Replies: 2
    Last Post: 08-17-2007, 06:50 AM
  3. Memory leak by simple char
    By Ktulu in forum C++ Programming
    Replies: 42
    Last Post: 11-05-2006, 12:59 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. Is it necessary to write a specific memory manager ?
    By Morglum in forum Game Programming
    Replies: 18
    Last Post: 07-01-2002, 01:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21