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

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

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