#include <iostream>
#include "Pizza.h"
int main() {
iFood* food;
food = new Pizza(14.0, 8);
for (int i = 0; i < 3; i++)
food->consume();
food->display();
std::cout << std::endl;
delete food;
food = new DeluxePizza(12.0, 6, "mushrooms, peppers");
for (int i = 0; i < 2; i++)
food->consume();
food->display();
std::cout << std::endl;
delete food;
}
这是我的main.cpp 当我运行这段代码时,它显示了在iFood上调用的删除警告,它是抽象的,但是具有非虚拟析构函数。
答案 0 :(得分:1)
您需要在virtual
中创建析构函数iFood
。