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

后端 未结 8 2085
余生分开走
余生分开走 2020-12-02 11:52

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 m

8条回答
  •  一个人的身影
    2020-12-02 12:39

    The .cpp file is the compilation unit : it's the real source code file that will be compiled (in C++).

    The .h (header) files are files that will be virtually copy/pasted in the .cpp files where the #include precompiler instruction appears. Once the headers code is inserted in the .cpp code, the compilation of the .cpp can start.

提交回复
热议问题