D
Dmytro Bablinyuk
I came across several possible ways of allocating memory for objects,
for example:
1. malloc(sizeof(T)*3)/free - raw memory
2. new T[3]/delete[] - buffer would be initialized to
default-constructed T objects.
3. operator new(sizeof(T)*3)/operator delete - raw memory
What the best way of allocating memory for simple types and objects?
For objects the "new T[3]" looks like the best way since it initializes
the array, but what about simple types?
Right now for "int *" I am using malloc, but would it be better if I use
"operator new" for instance? What the advantages?
for example:
1. malloc(sizeof(T)*3)/free - raw memory
2. new T[3]/delete[] - buffer would be initialized to
default-constructed T objects.
3. operator new(sizeof(T)*3)/operator delete - raw memory
What the best way of allocating memory for simple types and objects?
For objects the "new T[3]" looks like the best way since it initializes
the array, but what about simple types?
Right now for "int *" I am using malloc, but would it be better if I use
"operator new" for instance? What the advantages?