Hi all,
I have implemented overloaded function for operator new. In this function I have not allocated any memory still while exiting from program it is getting crashed.
Code is as below:
class A
{
public:
int a;
int b;
A()
{
cout<<"Inside A::A()"<<endl;
}
void* operator new(size_t s)
{
cout<<s<<endl;
cout<<"Inside A::new()"<<endl;
}
};
int main(int argc, char argv[])
{
A a= new A;
system("PAUSE");
return EXIT_SUCCESS;
}
Output of program is -
8
Inside A::new()
Inside A::A()
Crash