I am fairly new to C++. I encountered two ways of declaring member functions in c++, ie. Inside class and Outside Class. I searched about the differences and it says the functions that are defined inside class are treated as inline functions.
When I previously read about inline functions it stated that inline is just a request to the compiler to substitute function body instead of calling the functions. But if the function is complex (like recursive, contains static variables, switch etc.) then the compiler will ignore the request. So even if we declare the function inside class if it is complex compiler will ignore the request. Then what is the point of defining functions outside class, if we can just let this decision on compiler itself to automatically do it for us?
inline
has little to do with actual inlining and more to do with ODR (One Definition Rule). – Selfforgetfulinline
. You can read that straight out of the C++ standard. – Selfforgetful