What should go into an .h file?

后端 未结 12 835
伪装坚强ぢ
伪装坚强ぢ 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:48

    What compiles into nothing (zero binary footprint) goes into header file.

    Variables do not compile into nothing, but type declarations do (coz they only describe how variables behave).

    functions do not, but inline functions do (or macros), because they produce code only where called.

    templates are not code, they are only a recipe for creating code. so they also go in h files.

提交回复
热议问题