编译器错误 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
}
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈