Defining a member function inside the class instead of outside in C++?

前端 未结 4 689
北海茫月
北海茫月 2021-01-24 13:23

By writing the definition of a member function inside the class in the header file as follows, I was told that compiler treats this as an inline function - hence , anywhere it e

4条回答
  •  走了就别回头了
    2021-01-24 14:08

    If you define a function within a class definition, it is by default inline ( without needing to specify 'inline')

    The compiler replaces all instances of an inline function call with the actual code.

    Note: the compiler may ignore the 'inline' qualifier of a function if it is more than one line. You will also need to recompile all componnents (the ones which utilize that function) so that compiler can replace the code block with the new code.

提交回复
热议问题