C++ circular include

后端 未结 4 1205
野的像风
野的像风 2020-12-06 03:26

I can\'t solve this circular dependency problem; always getting this error: \"invalid use of incomplete type struct GemsGame\" I don\'t know why the compiler doesn\'t know t

4条回答
  •  囚心锁ツ
    2020-12-06 03:34

    Two ways out:

    1. Keep the dependent classes in the same H-file
    2. Turn dependency into abstract interfaces: GemElement implementing IGemElement and expecting for IGemsGame, and GemsGame implementing IGemsGame and containing a vector of IGemElement pointers.

提交回复
热议问题