Is is a good practice to put the definition of C++ classes into the header file?

前端 未结 5 1740
暖寄归人
暖寄归人 2020-12-02 09:01

When we design classes in Java, Vala, or C# we put the definition and declaration in the same source file. But in C++ it is traditionally preferred to separate the definitio

5条回答
  •  清歌不尽
    2020-12-02 09:39

    The biggest difference is that every function is declared as an inline function. Generally your compiler will be smart enough that this won't be a problem, but worst case scenario it will cause page faults on a regular basis and make your code embarrassingly slow. Usually the code is separated for design reasons, and not for performance.

提交回复
热议问题