Moule Lin
← All notes

Overloading new()

You can overload new, and also new()

Foo* p = new(300,”a”) Foo;

The arguments inside new() are the extra parameters you can add to the overloaded function
Note that the first parameter must be size_t

void* operator new(size_t size, int a, char c){
.....
}

This way you can write multiple versions of the overloaded new

delete() can also have multiple versions like this, matching the parameter versions of new().