Can we have a virtual static method ? (c++) [duplicate]
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: C++ static virtual members? Can we have a virtual static method (in C++) ? I've tried to compile the following code : #include <iostream> using namespace std; class A { public: virtual static void f() {cout << "A's static method" << endl;} }; class B :public A { public: static void f() {cout << "B's static method" << endl;} }; int main() { /* some code */ return 0; } but the compiler says that : member 'f'