上一页 1 ··· 80 81 82 83 84 85 86 87 88 ··· 92 下一页
摘要: #include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 1.2.2函数模板注意事项 自动类型推导,必须推导出一致的数据类型T,才可以使用 模板必须要确定出T的数据类型,才可以使用 */ templa 阅读全文
posted @ 2021-04-17 20:04 yub4by 阅读(66) 评论(0) 推荐(0)
摘要: #include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 1.1模板概念 C++另一种编程思想称为 泛型编程 ,主要利用的技术就是模板 C++提供两种模板机制:函数模板和类模板 */ /* 1.2函数 阅读全文
posted @ 2021-04-17 20:03 yub4by 阅读(57) 评论(0) 推荐(0)
摘要: work.h #pragma once#include#includeusing namespace std;// 职工抽象类class Worker{public: int id; string name; int dept_id; ... 阅读全文
posted @ 2021-04-17 15:17 yub4by 阅读(178) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.7.6 多态案例3--电脑组装 案例描述: 电脑主要组成部件为 CPU(用于计算),显卡(用于显示),内存条(用于存储)... 阅读全文
posted @ 2021-03-18 10:38 yub4by 阅读(51) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.7.5 虚析构和纯虚析构 多态使用时,如果子类中有属性开辟到堆区,那么父类指针在释放时无法调用到子类的析构代码 解决方式:将父类... 阅读全文
posted @ 2021-03-18 10:38 yub4by 阅读(41) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.7.3 纯虚函数和抽象类 在多态中,通常父类中虚函数的实现是毫无意义的,主要都是调用子类重写的内容,因此可以将虚函数改为纯虚函数 ... 阅读全文
posted @ 2021-03-18 10:37 yub4by 阅读(39) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.7.4 多态案例2--制作饮品 案例描述: 制作饮品的大致流程为:煮水 - 冲泡 - 倒入杯中 - 加入辅料 ... 阅读全文
posted @ 2021-03-18 10:37 yub4by 阅读(32) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.7.2 多态案例--计算器类 案例描述: 分别利用普通写法和多态技术,设计实现两个操作数进行运算的计算器类 ... 阅读全文
posted @ 2021-03-18 10:37 yub4by 阅读(71) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.7 多态 4.7.1 多态的基本概念 多态分两类: 静态多态:函数重载和运算符重载属于静态多态,复用函数名 ... 阅读全文
posted @ 2021-03-17 15:48 yub4by 阅读(29) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.6.8 菱形继承 两个派生类继承同一个基类,又有某个类同时继承者两个派生类,这种继承被称为菱形继承,或者钻石继承 例如:羊继... 阅读全文
posted @ 2021-03-17 13:33 yub4by 阅读(33) 评论(0) 推荐(0)
上一页 1 ··· 80 81 82 83 84 85 86 87 88 ··· 92 下一页