Forward declaration include, on top of declaration include (ClassFwd.h + Class.h)

前端 未结 4 1167
孤独总比滥情好
孤独总比滥情好 2020-12-16 01:08

In Effective C++ (3rd edition), Scott Meyers, in Item 31, suggests that classes should have, on top of their classic Declaration (.h) and Definition (.cpp) files, a Forward

4条回答
  •  佛祖请我去吃肉
    2020-12-16 01:25

    The practice allows the code user not to think about whether a class is regular or template. The user just #inludes "corresponding_fwd.h" file and has a class reference. One less annoyance for the user is A Good Thing. But if it's a small project or class' creator is the only class' user then it might be more annoyance. So, it depends.

提交回复
热议问题