Bit confused about usage of new to allocate memory dynamically.
e.g. If I need to allocate memory for 100 ints(assuming int is 4 bytes), should I say :
int *ptr = new int[100];
or
int *ptr = new int[100*4]; //assuming int is 4 bytes.
Basially new operator allocates memory in bytes or that many bytes of type T used while invoking the new operator?
If my class doesn't have a allocator member function defined, & i need to allocate an array of object of that class type, will the new oeprator find the sizeof(class type) and allocate accordingly or how would it work?
EDIT:
Sorry for clubbing multiple questions, but its related:
will this piece of code work fine if i want to allocate a 2D array of size [100][4] of ints
int *arr = new int [100][4];
thank you.
-AD