Sobes.tech
Junior — Senior

Declaration of interconnected classes with pointers to each other

livecode

Task condition

In the example, two classes A and B are declared, each of which stores a pointer to an object of the other class. The provided code does not compile. It is necessary to indicate what the error is in the declaration of class A, and to suggest a change after which the program compiles successfully.

class A {
    B* b;
};

class B {
    A* a;
};