+ 8
is it mandatory to define a member function outside the class
in a challenge they said every function defind inside the class is an inline function I read about inline function if the body of defined function is small , it is better make it inline so that the compiler deal with it as macros anyway it is bad to define a big function inline so should I define the function outside the class
8 Answers
+ 2
Outside the class is most common for all but the most trivial functions I'd say.
+ 4
but I can use inline keyword inside the class why all of them are inline without writing inline before them
if the compiler really considers that I will get my answer
+ 4
thanks master HonFu [#GoGetThatBugChamp!] precious information
+ 4
another precious information thanks Sonic .. but it is good practice to define it outside the class isn't it?
what about structures is it the same?
+ 4
I got it .. I appreciate your information
+ 3
If your function contains a loop or recursion or a switch or goto, the compiler may not decide to inline it.
+ 2
If you write it in the class, it will be inline automatically.
If you write it outside of the class and want it to be inline, you have to explicitly say it.
+ 1
From what you wrote, one can deduce:
If the body is big - yes.