IIRC, if you define an object of some kind, it must be a complete type, otherwise its size wouldn't be known and the layout of the struct
which would contain it couldn't be known.
Moreover the thing you wrote makes no sense, because if you wanted to create an object of type A
, it would include an object of type B
, which would contain an object of type A
, and so on. Thus, an object of type A
or of type B
would take infinite space in memory, which is definitely not good.
Instead, if those members were pointers/references the forward declarations would suffice and you wouldn't even have this "little" problem of requiring infinite memory for a structure. :)