I compiled the following code:
class B; class A { A(); friend AB::newAObject(); }; class B { friend A::A(); public: A newAObject(); };
This may seem strange, but the idea was to have a class A
that could only be created by an object of type B
(which would probably be single).
The problem is that I created a circular relationship between these objects. A
must be defined before B
, and B
must be defined before A
Obviously, forward declaring B
is not good enough, B
must be fully defined before A
(and vice versa).
How do I get around this?
Edit: actual error: Incomplete type "B" specified in the nested qualifier.
Note: there is another message similar to this here: Error: incomplete type used in the naming specifier , but it is strongly templatized, and this was confusing to me, therefore this post.
source share