Mechanism of Vptr and Vtable in C++

前端 未结 3 446
囚心锁ツ
囚心锁ツ 2020-12-03 03:58

In C++, during dynamic binding, consider the following example...

class Base
{
  virtual void fun()
  {
     cout<<\"Base\";
  }      
};

class Derive         


        
3条回答
  •  醉酒成梦
    2020-12-03 04:34

    The Standard doesn't specify the mechanism by which polymorphism is implemented. All the Standard says is how it should work -- not how compiler vendors should implement it.

    That being said, you have it pretty much right as far as GCC under Linux and MSVC under Windows is concerned, and I would expect most other compilers to be similar.

提交回复
热议问题