-------------------------
example:
class CFoo
{
public:
CFoo(){}
virtual ~CFoo(){}
// overloaded new operator
void* operator new (size_t size);
// overloaded new[] operator
void* operator new [] (size_t size);
};
void* CFoo :: operator new (size_t size)
{
return NULL;
}
void* CFoo :: operator new [] (size_t size)
{
return NULL;
}
----------------------------------------
note: don't forget to overload new[] also
otherwise, will allow to create dynamic creation when trying to create arrays.
No comments:
Post a Comment