If I overload operators new and delete for a class with a nested class:
class A
{
public:
static void* operator new(size_t);
static void operator delete(void*);
class B;
}
Will allocations for instances of A::B objects and allocations within A::B objects use the overloaded A::new and A::delete or the global defaults?
First of all, chances are very high that you do not need to overload
newnordeleteand should avoid doing so.Baring that, the overloaded operators are going to apply to class
A, not to classA::B. If you wanted to have B with overloaded operators, you would need to overload them in classBas well.For an example of how to overload
newanddelete: http://www.cprogramming.com/tutorial/operator_new.html