请教关于C++的基础问题
#include<iostream>
using namespace std;
class X
{
private:
int a;
public:
X () : a(0) {}
X(int i) : a(i)
{
cout << "Creamting" << endl;
}
~X() {}
void show()
{
cout << a << endl;
}
void* operator new (size_t sz)
{
cout << "Creating" << endl;
void* x = new X(sz);
return x;
}
void operator delete(void *x)
{
cout << " deleting" << endl;
delete x;
}
};
int main()
{
X* m;
m = new X(5);
delete m;
return 0;
}
中的
void* operator new (size_t sz)
{
cout << "Creating" << endl;
void* x = new X(sz);
return x;
}
void operator delete(void *x)
{
cout << " deleting" << endl;
delete x;
}
都是无限嵌套函数么?,为什么啊?
请大侠帮我解释下好么?小弟在这里谢谢大家了