Suppose we wan't to hint the compiler to inline member function where applicable.
class Base
{
public:
inline virtual f() = 0;
};
class Derived : public Base
{
public:
virtual f() override; // no inline specifier here
};
Do I need to specify inline
in Derived::f()
or can I omit the keyword and be sure that virtual Derived::f()
is the same thing as inline Derived::f()
?
I mean is the inline
keyword implicitly specified for Derived::f()
or do I need to explicitly type it once again?
Do I need to specify
inline
inDerived::f()
or can I omit the keyword and be sure thatvirtual Derived::f()
is the same thing asinline Derived::f()
?
If you omit the inline
keyword in the derived class, it is not inline
in the derived class.
I mean is the
inline
keyword implicitly specified forDerived::f()
No, it is not.
or do I need to explicitly type it once again?
Yes, you do. However, a compiler will most likely generate code for it as though it is a non-inline
member function since it is a virtual
member function.