c++ - Static object in struct -


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

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -