Search code examples
c++virtualinline

what will happen to inline functions inside virtual functions?


What will happen if I use a inline function inside a virtual function? I'm confused with questions like http://www.parashift.com/c++-faq-lite/value-vs-ref-semantics.html#faq-31.6

I can understand it, but is that mean, it will non-sense to use (call) inline functions inside virtual functions (please assume that it is calling dynamically)?

class Wrapper
{
public:
   inline void doInlineJob() {;}
};

class Base
{
   virtual void foo()
   {
     //Do something
   }
};

class Derived: public Base
{
    void foo()
    {
      wrapObj.doInlineJob();
    }

    Wrapper wrapObj;
};

Solution

  • It doesn't matter whether foo is virtual or not. It only matters whether doInlineJob is virtual. It's not, so it can be inlined without a problem.