虚函数表构建时机
#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