I have two classes referring to each other, but when i try to compile the code I get these errors,
jw-mytest$g++ -o mytest foo.cpp boo.cpp
foo.cpp: In member function 'boo* foo::getBoo()':
foo.cpp:4: error: invalid use of undefined type 'struct boo'
foo.h:3: error: forward declaration of 'struct boo'
The code is below:
Is it possible to even to do this?Code://FILE - boo.h #ifndef BOO_H #define BOO_H #include "foo.h" class boo { public: boo(); foo* getFoo(); }; #endif //FILE - boo.cpp #include "boo.h" boo::boo() { } foo* boo::getFoo() { return new foo(); } //FILE - foo.h #ifndef FOO_H #define FOO_H class boo; class foo { public: foo(); boo* getBoo(); }; #endif //FILE - foo.cpp #include "foo.h" foo::foo() { } boo* foo::getBoo() { return new boo(); }



LinkBack URL
About LinkBacks



Want to add some