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

前端 未结 4 720
北海茫月
北海茫月 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:01

    You are right that the function with definition in the header file is implicitly "inline". But the inline keyword is just a hint to the compiler. Depending on its implementation, on the function contents and on the optimization flags, the compiler may decide to inline a function or not.

提交回复
热议问题