c++ - Linker error : undefined reference to -
this question has answer here:
i wrote program static variable. however, getting following error :
[linker error] c:/users/prcm/documents/practice/junk.cpp:8: undefined reference `x::a'
here code
#include <iostream> using namespace std; class x { public: static const int a; public: static int geta() { return a; } }; int main() { cout<< x::geta()<< endl; return 0; }
it's right, have never defined x::a
.
put following line after class declaration: const int x::a = 0;
Comments
Post a Comment