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

前端 未结 5 1736
暖寄归人
暖寄归人 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条回答
  •  萌比男神i
    2020-12-02 09:38

    The drawback of putting definition in header files is as follows:-

    Header file A - contains definition of metahodA()

    Header file B - includes header file A.

    Now let us say you change the definition of methodA. You would need to compile file A as well as B because of the inclusion of header file A in B.

提交回复
热议问题