What should go into an .h file?

后端 未结 12 934
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 15:26

When dividing your code up into multiple files just what exactly should go into an .h file and what should go into a .cpp file?

12条回答
  •  [愿得一人]
    2020-11-22 15:42

    I'd expect to see:

    • declarations
    • comments
    • definitions marked inline
    • templates

    the really answer though is what not to put in:

    • definitons (can lead to things being multiply defined)
    • using declarations/directives (forces them on anyone including your header, can cause nameclashes)

提交回复
热议问题