I wrote a program with static variable. However, the I am getting the following error :
[Linker error] C:/Users/prcm/Documents/Practice/junk.cpp:8: undefined reference to `X::a'
Here is the 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;
}