I have two objects of classes (A and B) which must be able to refer to each other, e.g.:
class A {
public:
A(B& b);
private:
B& b;
};
class B {
public:
B(A& a);
private:
A& a;
};
But I can't do this:
A a(b);
B b(a);
With pointers this would be easy, as a pointer can be NULL. How can I achieve the same result using references, or is it not possible?