This question already has an answer here:
- C++ class forward declaration 8 answers
There is a Square
which points to four Face
s. Also each Face
points to two Square
s. Since one of the classes is defined first, compiler will complain. So how can I solve this problem? The aim of using pointers is that if I make a change in a face I will not need to make any changes for squares. In that case, this will be done automatically.
class Square
{
Face* faces[4];
};
class Face
{
Square* squares[2]
};