What are the drawbacks of forward declaration?

前端 未结 5 1363
暗喜
暗喜 2021-01-14 13:09

I am wondering if there is any drawback for using forward declarations in all places when possible. This is if my header contains only declarations.

As far as I unde

5条回答
  •  太阳男子
    2021-01-14 13:41

    Forward declaration is the only way to break the cyclic inclusion.

    This is the main drawback when not used carefully, I think. I worked in a large project where forward declarations are made whenever possible. Cyclic dependencies were a real problem in the end.

提交回复
热议问题