Categories
C++ Visual Studio

error C2724: ‘ClassName::FunctionName’ : ‘static’ should not be used on member functions defined at file scope

Full error message: error C2724: ‘ClassName::FunctionName’ : ‘static’ should not be used on member functions defined at file scope

Error occurred in Visual Studio 2003 while declaring a static function.

Header file:

class MyClass {
public:
static void FunctionName();
};

Source file:

static void MyClass::FunctionName() {
return 0;
}

The error occurs because i used the ‘static’ modifier in the source file as well as the header file.

The fix is: Remove the ‘static’ modifier from the source file

So the code in the source file will become:

void MyClass::FunctionName() {
return 0;
}

2 replies on “error C2724: ‘ClassName::FunctionName’ : ‘static’ should not be used on member functions defined at file scope”

Comments are closed.