虚函数表构建时机

#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
posted @ 2022-08-17 07:48  thomas_blog  阅读(18)  评论(0编辑  收藏  举报