c++ - Linker error : undefined reference to -


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

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -