How can a C++ header file include implementation?

前端 未结 7 1733
有刺的猬
有刺的猬 2020-11-28 02:51

Ok, not a C/C++ expert by any means, but I thought the point of a header file was to declare the functions, then the C/CPP file was to define the implementation.

How

7条回答
  •  爱一瞬间的悲伤
    2020-11-28 03:51

    Keeping the implementation in the class header file works, as I'm sure you know if you compiled your code. The const keyword ensures you don't change any members, it keeps the instance immutable for the duration of the method call.

提交回复
热议问题