I have written a trivial class that overloads the new operator:
class A {
public:
A();
void* operator new(size_t size);
void operator delete(void* p);
int getX(void);
void setX(int i);
private:
int x ;
};
I set a breakpoint in my implementation for the new operator. Some where
in my code, I have a line like this:
A *a_obj = new A ;
The size argument passed to my 'new' function was 4 (presumably bytes?)
I am guessing that this is the sizeof(A)?
Is this the general case?. I mean what if I had a much more complecated
class (say with nested pointers and structures etc?).
Is it really sizeof(A) that is being passed to my 'new' function?