其他分享
首页 > 其他分享> > 虚函数表构建时机

虚函数表构建时机

作者:互联网

#include <iostream>

class Base
{
public:
   Base()
   {
      func();
   }

   ~Base()
   {
      func();
   }

   virtual void func()
   {
      std::cout << "Base func" << std::endl;
   }
};

class Work
{
public:
   virtual void func()
   {
      std::cout << "Work func" << std::endl;
   }
};

int main()
{
   Base base;

   return 0;
}
$ ./a.out 
Base func
Base func

标签:std,函数,void,virtual,Base,构建,func,时机,public
来源: https://www.cnblogs.com/zhangxuechao/p/16593604.html