In the following example, the front declaration declaration of struct Y fooward is not enough. If you comment out X :: b, it compiles fine, since Y has a complete declaration of the structure to work with, but X has only a forward declaration.
#include <functional>
Ideone
Below is a fix I could come up with:
#include <functional>
Ideone
And although it works in this example, if the classes were polymorphic, children of these classes would need to use using X::X; or using Y::Y; .
Is there a way to do this in the header files themselves?
source share