C++ "class Foo return Bar" and "class Bar return Foo" possible?
Is it possible to define C++ classes Foo and Bar s.t.
clas开发者_如何学JAVAs Foo {
Bar makeBar();
};
class Bar {
Foo makeFoo();
};
?
Thanks!
Yes it is, you just have to put forward declarations at the top.
class Foo;
class Bar;
class Foo {
Bar makeBar();
};
class Bar {
Foo makeFoo();
};
Yes. You can do it with a forward declaration.
For example, in Foo.h
, add:
class Bar;
class Foo {
Bar makeBar();
};
精彩评论