C++ virtual destructor, virtual function, pure virtual function, virtual function pointer, virtual function table

Virtual destructor The
virtual destructor is to solve the problem that the pointer of the base class points to the derived class object and delete the derived class object with the base class pointer.
Use of virtual destructor

class Shape
{
   
    
    
public:
    Shape();                    // 构造函数不能是虚函数
    virtual double calcArea();
    virtual ~Shape();           // 虚析构函数
};
class Circle : public Shape     // 圆形类
{
   
    
    
public:
    virtual double calcArea()

Guess you like

Origin blog.csdn.net/it_xiangqiang/article/details/113103204