编译器错误 C2801
“operator operator”必须是非静态成员
以下运算符只能作为非静态成员重载:
分配
=
类成员访问
->
下标
[]
函数调用
()
可能的 C2801 原因:
重载运算符不为类、结构或联合成员。
重载运算符声明为
static
。以下示例生成 C2801:
// C2801.cpp
// compile with: /c
operator[](); // C2801 not a member
class A {
static operator->(); // C2801 static
operator()(); // OK
};
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈