Here is some code I've read which overloads the new operator for a class, I have a couple of syntax questions about it
Now new returns a memory address (I believe) so is void* what a function must return if it is to return that?Code:void *three_d::operator new[](size_t size) { void *p; cout << "Allocating array of three_d objects.\n"; // throw an exception on failure p = malloc(size); if(!p) { bad_alloc ba; throw ba; } return p; }
Also, this is overloading new to allocate memory for an array of objects, but I don't see how the code would change if we were to simply overload new normally?
Sorry if these questions seem a little trivial, but they've been bugging me for a couple of days now
Stonehambey