class a{
public:
int b;
static int c;
virtual void mod() const
{
c=4;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
a bi;
return 0;
}
Look at this ... After compiling it using Visual Studio C++ 2010 compiler, I get...
cpplearningconsole.obj : error LNK2001: unresolved external symbol "public: static int a::c" (?c@a@@2HA)
I guess this is a compiler bug. For me, the real question is. Should mod be able to modify c variable if it is const?
Thanks.
You have just declared the static variable in the class definition, you need to define it in the by doing int a::c = 0;
.