摘要:
#include#include#includeusing namespace std;/* 4.7.5 虚析构和纯虚析构 多态使用时,如果子类中有属性开辟到堆区,那么父类指针在释放时无法调用到子类的析构代码 解决方式:将父类... 阅读全文
posted @ 2021-03-18 10:38
yub4by
阅读(31)
评论(0)
推荐(0)
摘要:
#include#include#includeusing namespace std;/* 4.7.2 多态案例--计算器类 案例描述: 分别利用普通写法和多态技术,设计实现两个操作数进行运算的计算器类 ... 阅读全文
posted @ 2021-03-18 10:37
yub4by
阅读(68)
评论(0)
推荐(0)
摘要:
#include#include#includeusing namespace std;/* 4.7.3 纯虚函数和抽象类 在多态中,通常父类中虚函数的实现是毫无意义的,主要都是调用子类重写的内容,因此可以将虚函数改为纯虚函数 ... 阅读全文
posted @ 2021-03-18 10:37
yub4by
阅读(33)
评论(0)
推荐(0)
摘要:
#include#include#includeusing namespace std;/* 4.7.4 多态案例2--制作饮品 案例描述: 制作饮品的大致流程为:煮水 - 冲泡 - 倒入杯中 - 加入辅料 ... 阅读全文
posted @ 2021-03-18 10:37
yub4by
阅读(22)
评论(0)
推荐(0)