Thread: creating objects in c++

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    7

    creating objects in c++

    what exactly are the differences in the following??
    like to create a array of XX objects is
    XX obj[3];

    What does it mean by the following?
    1. creating an array of XX object pointers
    2. dynamic array of XX objects
    3.dynamic array of XX object pointers

    how can you create a Dynamic 'array'???
    i'm confused
    pl help me out

  2. #2
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    715
    statement
    XX obj[3];
    mens that memory is reserved in comile time not run time. So you cannot change length of array in runtime;

    Code:
    XX *obj =new XX[3];
    means that memory is allocated in run time so you can ask user to enter number of objcets for example N and reserve memory for N objects on heap 
    XX *obj =new XX[N];
    dynamic array of XX object pointers
    is something like this:
    Code:
    XX **obj =new XX*[N];

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Dynamic allocation implies allocating/deallocating memory at runtime.

    Kuphryn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  2. Creating array of objects w/o default constructor
    By QuestionC in forum C++ Programming
    Replies: 19
    Last Post: 05-02-2007, 08:03 PM
  3. Creating Objects + Array
    By Cpro in forum C++ Programming
    Replies: 3
    Last Post: 04-01-2007, 11:14 PM
  4. Creating vectors of objects!
    By bobthebullet990 in forum C++ Programming
    Replies: 17
    Last Post: 08-08-2006, 04:51 PM
  5. creating new objects in loop
    By Joe_Gibbs in forum C++ Programming
    Replies: 3
    Last Post: 04-10-2004, 09:04 AM