Can you define a static member function in a class?
Is there any regulation about where to define a static member function? My question is, can you define the static member function in a separated .cpp file? Or you have to define it in its .h file?
suppose you have a class in a test.h file
Code:
class A{
public:
static void foo();
};
Then, in the main.cpp file, you include the test.h and give foo() a definition.
Code:
void A::foo(){
....//do something
}
It works in my PC, but my friend says that's incorrect.