vs code配置 c++ delete命令报警

在class computer的析构函数中的三个if语句中的delete会有警告提示(delete called on 'VIDEOCARD' that is abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor]),void test1()中的delete却没有报警。在vs2019中4个delete均没有警告提示,请问是不是我的vscode配置有问题,还请各位指点一下,我应该如何修改vscode的配置


#include <iostream>
#include <string>
using namespace std;
//create abstract base class
class CPU{
     public:
     virtual void process() = 0;//接口
};
class VIDEOCARD{
     public:  
     virtual void display() = 0;
};
class MEMORY{
     public:  
     virtual void storage() = 0;
};
//generate a computer
class computer{
     public://构造函数初始化对象
     computer(CPU *cpu, VIDEOCARD *videocard, MEMORY *memory)//作用是CPU *m_cpu=   new interorlenovo
     {
          cout << "构造函数调用" << endl;
          m_cpu = cpu;
          m_videocard = videocard;
          m_memory = memory;

     }
     ~computer(){
          cout << "析构函数调用" << endl;
          if (m_cpu != NULL)
          {
                  delete m_cpu;                       //这三个if语句中的delete会有报警提示
                  cout << "delete m_cpu done" << endl;
          }
          if (m_videocard != NULL)
          {
               delete m_videocard;
               cout << "delete m_videocard done" << endl;
          }
          if (m_memory != NULL)
          {
               delete m_memory;
               cout << "delete m_memory done" << endl;
          }
     }
     public:
     CPU *m_cpu;
     VIDEOCARD *m_videocard;
     MEMORY *m_memory;
};
//specify factory to generate the part of computer
class intercpu: public CPU{
     public:
     virtual void process(){//具体实现
          cout << "使用inter cpu组装电脑" << endl;
     }
};
class intervideocard: public VIDEOCARD{
     public:
     virtual void display(){//具体实现
          cout << "使用inter 显卡组装电脑" << endl;
     }
};
class intermemory: public MEMORY{
     public:
     virtual void storage(){//具体实现
          cout << "使用inter 内存条组装电脑" << endl;
     }
};

//测试例子
void test0(){
     CPU *Cpu = new intercpu;
     VIDEOCARD *Videocard = new intervideocard;
     MEMORY *Memory = new intermemory;

     computer Computer(intercpu, intervideocard, intermemory);
     Cpu->process(); Videocard->display(); Memory->storage();
     
     // delete 

}
void test1(){
     computer * com = new computer(new intercpu, new intervideocard, new intermemory);
     com->m_cpu->process(); com->m_videocard->display(); com->m_memory->storage();
     delete com; //这里没有报警
}
int main(){

     test0();
     cout << "-————————————————————————————————————" << endl;
     test1();
     return 0;
}





在class computer的析构函数中的三个if语句中的delete会有警告提示(delete called on 'VIDEOCARD' that is abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor]),void test1()中的delete没有警报提示。在vs2019中4个delete均没有警告提示,请问是不是我的vscode配置有问题,还请各位指点一下,我应该如何修改vscode的配置

已经解决了,在相应的类中加入虚析构函数就没有报警,最近刚开始学类,对类的语法还不是很熟悉。但是不明白为什么vscode会报警,而vs2019不报警,希望知道原因的的哥哥姐姐看到这里帮我解答一下,

你好,我是有问必答小助手,本次您提出的问题,已经自行解答


本次提问扣除的有问必答次数,将会以问答VIP体验卡(1次有问必答机会、商城购买实体图书享受95折优惠)的形式为您补发到账户。


因为有问必答VIP体验卡有效期仅有1天,您在需要使用的时候【私信】联系我,我会为您补发。