Operator new 的全局重载 原文地址:http://blog.csdn.net/zhenjing/article/details/4354880 我们经常看到这么一句话: operator new 可以重载, placement new 不可重载.其实此处所说的不可重载应该是指全局的 placement new 不可重载,对于类域中的 placement new 是可以重载的,而且只要重载了任何一种形式的 operator new 都应该顺便重载 placement new , 即 v
#include <iostream> class A { public: int i; public: void* operator new (size_t a, size_t b) { std::cout << "a: " << a << ",b: " << b << std::endl; return NULL; } }; int main() { A *pInt = NULL; pInt