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

前端 未结 6 683
醉酒成梦
醉酒成梦 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:15

    It doesn't have to be inlined, no; it's just like if you specified inline explicitly.

    When you write inline, you promise that this method won't be called from translation units where it isn't defined, and therefore, that it can have internal linkage (so the linker won't connect one object-file's reference to it to another object-file's definition of it). [This paragraph was wrong. I'm leaving it intact, just struck-out, so that the below comments will still make sense.]

提交回复
热议问题