-
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
-
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];
-
Dynamic allocation implies allocating/deallocating memory at runtime.
Kuphryn