C
Clement Courbet
Hi,
I have a simple question concerning arrays of primitive types
allocated/deallocated via operator new[]/delete[]:
On non-primitive types, new[] will allocate memory, then call the
constructor for each object. What about primitive types ? Is there an
overhead for:
int *intPointer = new int[1000000];
compared to simple memory allocation ?
To go further, if I have a class which has an empty constructor, and
only primitive type class members, let's say
class A
{
public:
A{};
~A{};
private:
int anInt;
char aChar;
};
then will a call to
A *aPointer = new A[1000000];
generate a loop calling the useless constructor ?
thank you for your answers,
I have a simple question concerning arrays of primitive types
allocated/deallocated via operator new[]/delete[]:
On non-primitive types, new[] will allocate memory, then call the
constructor for each object. What about primitive types ? Is there an
overhead for:
int *intPointer = new int[1000000];
compared to simple memory allocation ?
To go further, if I have a class which has an empty constructor, and
only primitive type class members, let's say
class A
{
public:
A{};
~A{};
private:
int anInt;
char aChar;
};
then will a call to
A *aPointer = new A[1000000];
generate a loop calling the useless constructor ?
thank you for your answers,