What are the in-line and not in-line method definitions (member function) in C++, and what is the difference between them? please provide some examples for both, thanks!
What are the in-line and not in-line method definitions (member function) in C++, and what is the difference between them? please provide some examples for both, thanks!
In C++ inline functions just start with the word inline. For example inline void myFunc()
Inline is a hint to the compiler that instead of calling this function via a call opcode when it compiles it, that it should instead insert the code of the function anywhere its called. This reduces the overhead of calling the function at the cost of additional executable size.
Notice I said its a hint. The compiler does not have to follow it. It will use its own best judgement on whether you're right or not. Really except in very niche circumstances you shouldn't be doing this, let the compiler decide when its more optimal to inline or not.