c++ - How do I define an object in the header file? (without using it) -


sorry if question title isn't confusing i'm not sure how word better.

basically, here code.

header file

class foo {      public:            foo();      private:            bar * b; }  class bar {      public:           bar(foo *f);      private:           foo * foo; } 

cpp file

foo::foo() {      new bar(this); }  bar::bar(foo * f) {      foo = f; } 

i trying pass values each other , forth bar not declared foo. how make bar known foo? sorry bad grammar. tired , can't think right.

class bar;  // <-- forward declaration.  class foo {      public:            foo();      private:            bar * b; } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -