Some points about 'inline'.
- inline on a virtual member is ignored. It's impossible to have an inline virtual.
If the compiler can determine the dynamic type of an object at compile time, then it most certainly can omit virtual lookup, and either call the function directly or unroll it inline if it so chooses.
Consider this code:
class base
{
public:
virtual void SomeFunction()
{
cout << "In base::SomeFunction" << endl;
}
};
class derived : public base
{
public:
virtual void SomeFunction()
{
cout << "In derived::SomeFunction" << endl;
}
};
void f()
{
derived d;
d.SomeFunction();
}
The compiler can optimize f() any way it sees fit. In fact, it
could compile the code as if you had written:
void f()
{
cout << "In derived::SomeFunction" << endl;
}
since there is no observable difference between that and what you wrote.
Edit:
minor edit to clean up mis-matched 'list' tags