编译器错误 C2801
“operator operator”必须是非静态成员
以下运算符只能作为非静态成员重载:
分配
=
类成员访问
->
下标
[]
函数调用
()
可能的 C2801 原因:
重载运算符不为类、结构或联合成员。
重载运算符声明为
static
。以下示例生成 C2801:
// C2801.cpp
// compile with: /c
operator[](); // C2801 not a member
class A {
static operator->(); // C2801 static
operator()(); // OK
};