error: expected class-name before ‘{’ token

前端 未结 5 707
独厮守ぢ
独厮守ぢ 2020-11-30 05:41

I know there are a couple of similar questions(circular include) out stackoverflow and other websites. But I still can\'t figure it out and no solutions pop out. So I would

5条回答
  •  感动是毒
    2020-11-30 06:07

    If you forward-declare Flight and Landing in Event.h, then you should be fixed.

    Remember to #include "Flight.h" and #include "Landing.h" in your implementation file for Event.

    The general rule of thumb is: if you derive from it, or compose from it, or use it by value, the compiler must know its full definition at the time of declaration. If you compose from a pointer-to-it, the compiler will know how big a pointer is. Similarly, if you pass a reference to it, the compiler will know how big the reference is, too.

提交回复
热议问题