Are C++ class methods defined in the header always inlined?

前端 未结 6 775
醉酒成梦
醉酒成梦 2021-01-12 01:05

Edit: I\'ve restored the original title but really what I should have asked was this: \'How do C++ linkers handle class methods which have be

6条回答
  •  [愿得一人]
    2021-01-12 01:16

    The inline keyword deals with c++ definition of a function. The compiler may inline object code where ever it wants.

    Functions defined inline (eg they use the inline keyword), create object code for the function in every compilation unit. Those functions are marked as special so the linker knows to only use one.

    See this answer for more specifics.

提交回复
热议问题