class Base
{
public:
virtual void func1()
{
std::cout<<"Base func1"<<std::endl;
}
//virtual destructor
};
class Derived : public Base
{
public:
virtual void func1()
{
std::cout<<"Derived Base func1"<<std::endl;
}
virtual void func2()
{
std::cout<<"Derived func2"<<std::endl;
}
};
int main()
{
Derived *d = new Derived;
delete d;
}
我想知道是否为解析虚函数创建了两个“vptr”,一个在“基”类中,它将在 func1() 的派生类对象中继承,另一个在 func2() 的“派生”对象中。