编译器错误 C2352
“class::function”:非静态成员函数的非法调用
static
成员函数调用了非静态成员函数。 或者,从类外部将非静态成员函数作为静态函数进行了调用。
下面的示例生成 C2352,并演示如何修复此错误:
// C2352.cpp
// compile with: /c
class CMyClass {
public:
static void func1();
void func2();
static void func3() {
func2(); // C2352 calls nonstatic func2
func1(); // OK calls static func1
}
};
下面的示例生成 C2352,并演示如何修复此错误:
// C2352b.cpp
class MyClass {
public:
void MyFunc() {}
static void MyFunc2() {}
};
int main() {
MyClass::MyFunc(); // C2352
MyClass::MyFunc2(); // OK
}
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈