Reputation: 42677
Is it possible to define C++ classes Foo and Bar s.t.
class Foo {
Bar makeBar();
};
class Bar {
Foo makeFoo();
};
?
Thanks!
Upvotes: 1
Views: 440
Reputation: 16229
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();
};
Upvotes: 8
Reputation: 564691
Yes. You can do it with a forward declaration.
For example, in Foo.h
, add:
class Bar;
class Foo {
Bar makeBar();
};
Upvotes: 2