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
Post a Comment