Iīve been reading about overloading the new operator in classes and I canīt get a thing. Lets say I declare a class
and a pointer to a Test classCode:class Test { public: void *operator new (size_t); private: };
Does this allocate memory on the heap(implicity) or do I have to do it explicity in the member-function newCode:Test *pToTest = new Test;
I would also appreciate if someone could give me an example when this kind of overloadning would be appropriate. Is this used to create some kind of "smart" pointer or what, becuase I have always been satisfied with the global new().Code:void * Test::operator new(size_t howbig) { //Envoke global new() to allocate ??? //and extra stuff }