编译器错误 C2323
“identifier”:非成员运算符 new
或 delete
函数不可声明为 static
,也不可在全局命名空间之外的命名空间中进行声明。
new
和 delete
重载运算符必须是非静态的,并在全局命名空间或类成员中定义。
以下会生成 C2323:
// C2323.cpp
// compile with: /c
static void* operator new(size_t); // C2323 since static
static void operator delete(void*); // C2323 since static
namespace NS
{
void* operator new(size_t); // C2323 since not defined in the global namespace
void operator delete(void*); // C2323 since not defined in the global namespace
}