In the following code:
class Base
{
void funcA();
void funcB();
.
.
};
class Derv : public Base
{
int m_state;
void funcA(){ m_state = 1; Base::funcA(); }
void funcB(){ m_state = 4; Base::funcB(); }
.
.
};
Derv a;
a.funcA();
Will Base::funcA() be a separate function call(Derv::FuncA() -> Base:FuncA()), or the code will be inlined?
if it is compiler dependent, does the compilers (e.x GCC) is smart enough to inline it?
It depends on implementation of
Base::funcA()andBase::funcB().If the compiler can then the compiler will inline it.
Most of the Modern day compilers(including gcc) are smart enough to do that.
The C++ standard allows a compiler to perform any optimization As long as the resulting executable exhibits the same observable behaviour as if all the requirements of the standard have been fulfilled.
This is known as the As-If Rule.