Possible Duplicate:
C++: undefined reference to static class member
The following C++ code compiles well (using g++ -c
) but it doesn't link giving the error: undefined reference to
Abc::X'`
#include <iostream>
using namespace std;
class Abc {
public:
const static int X = 99;
};
int main()
{
Abc a1;
cout << &(Abc::X) << endl;
}
I want to know why this is not allowed?