You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when the function is called, it moves to the codes where the function body is and come back to the original position.
Inline member function
compiler inserts the function body codes into the place of each function call
advantage :
can make the program faster
since it eliminates the process of jumping and coming back ( avoids overhead for function call)
overhead : additional cost (time)
disadvantage :
the size of the program can be unnecessarily bigger
In most case, the rate of how much the speed is increased is little and it can make the program size unnecessarily bigger so inline function is not used. But there exist some cases that it's significant, not negligible and useful
the cases when the inline function is used
when the function is very short like 1 or 2 lines long.
when the function is called within a loop with a lot of iterations
how to declare the inline function
put the keyword 'inline' in front of the signature of the function declaration
when the definition of the member function is inside of the class, it's automatically become an inline function
The text was updated successfully, but these errors were encountered:
Inline member function
The text was updated successfully, but these errors were encountered: