全局new和宏结合起来的一个小应用

 1 #include <iostream>
 2 using namespace std;
 3 
 4 void* operator new(size_t size, const char* file, int line)
 5 {
 6     cout << file << " : " << line << endl;
 7     cout << "size : " << size << endl;
 8     return ::new char[size];
 9 }
10 #define new new(__FILE__,__LINE__)
11 
12 int main()
13 {
14     int* a = new int;
15     delete a;
16 }

猜你喜欢

转载自www.cnblogs.com/XiaoXiaoShuai-/p/11650652.html