c++ - Static object in struct -
this question has answer here:
i have class a method display(). create struct b static variable of type object a:
class a{ public : void display() { cout << "in " << endl; } }; typedef struct b{ static a; } bb; //b::a.display(); int main() { bb b; bb::a.display(); return 0; } now error when try access a.
how can define static object in case?
you declared static a; did not define it. add following line before int main() , it'll link successfully:
a b::a;
Comments
Post a Comment