Why put a class declaration and definition in two separate files in C++?

前端 未结 7 1404
野性不改
野性不改 2021-01-01 16:16

I\'m just wondering, what is the whole point of separating classes into an .h and a .cpp file? It makes it harder to edit, and if your class won\'t be compiled into a .lib o

7条回答
  •  迷失自我
    2021-01-01 17:13

    Because even within your DLL other classes will use your class. Those files must see the class declaration at compile time, by including the .h. They must not see the definition or there will be multiple definitions of the class functions.

提交回复
热议问题