What is the difference between a .cpp file and a .

2019-01-10 22:16发布

Because I've made .cpp files then transfered them into .h files, the only difference I can find is that you can't #include .cpp files. Is there any difference that I am missing?

8条回答
唯我独甜
2楼-- · 2019-01-10 22:47

A good rule of thumb is ".h files should have declarations [potentially] used by multiple source files, but no code that gets run."

查看更多
劳资没心,怎么记你
3楼-- · 2019-01-10 22:54

By convention, .h files are included by other files, and never compiled directly by themselves. .cpp files are - again, by convention - the roots of the compilation process; they include .h files directly or indirectly, but generally not .cpp files.

查看更多
登录 后发表回答