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

前端 未结 7 1406
野性不改
野性不改 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.

    0 讨论(0)
提交回复
热议问题