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

后端 未结 8 2083
余生分开走
余生分开走 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:40

    Others have already offered good explanations, but I thought I should clarify the differences between the various extensions:

      Source Files for C: .c
      Header Files for C: .h
    
      Source Files for C++: .cpp
      Header Files for C++: .hpp
    

    Of course, as it has already been pointed out, these are just conventions. The compiler doesn't actually pay any attention to them - it's purely for the benefit of the coder.

提交回复
热议问题