上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 32 下一页
  2021年8月9日
摘要: 1 //纯虚函数和抽象类 2 // 语法 virtual 返回值类型 函数名 (参数列表)=0 3 //当类中有了纯虚函数 这个类也称为抽象类 4 5 6 #include <iostream> 7 #include <string> 8 using namespace std; 9 10 clas 阅读全文
posted @ 2021-08-09 08:43 Bytezero! 阅读(103) 评论(0) 推荐(0) 编辑
  2021年8月8日
摘要: 1 //多态案例 -计算器类(普通写法 和 多态写法) 2 3 #include <iostream> 4 #include <string> 5 using namespace std; 6 7 //普通实现 8 class Calualtor 9 { 10 public: 11 12 int g 阅读全文
posted @ 2021-08-08 17:55 Bytezero! 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 1 //多态 2 //静态多态:函数重载 和 运算符重载 属于静态多态 ,复用函数名 3 //动态多态:派生类和虚函数实现运行时多态 4 5 //静态多态和动态多态的区别 6 //静态多态的函数地址早绑定 - 编译阶段确定函数地址 7 //动态多态的函数地址晚绑定 - 运行阶段确定函数地址 8 9 阅读全文
posted @ 2021-08-08 16:21 Bytezero! 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 1 //菱形继承 2 //俩个派生类继承同一个基类 3 //又有某个类同时继承俩个派生类 4 //成为 菱形继承 或者 钻石 继承 5 6 #include <iostream> 7 #include <string> 8 using namespace std; 9 10 //动物类 11 12 阅读全文
posted @ 2021-08-08 12:23 Bytezero! 阅读(50) 评论(0) 推荐(0) 编辑
摘要: 1 //多继承语法 C++中允许一个类继承多个类 2 #include <iostream> 3 #include <string> 4 using namespace std; 5 6 class Base1 7 { 8 public: 9 Base1() 10 { 11 m_A = 100; 1 阅读全文
posted @ 2021-08-08 11:38 Bytezero! 阅读(1083) 评论(0) 推荐(0) 编辑
摘要: 1 //继承同名静态成员处理方式 2 #include <iostream> 3 #include <string> 4 using namespace std; 5 6 class Base 7 { 8 public: 9 static int m_A; 10 11 static void fun 阅读全文
posted @ 2021-08-08 11:21 Bytezero! 阅读(67) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <string> 3 using namespace std; 4 5 class Base 6 { 7 public: 8 Base() 9 { 10 m_A = 100; 11 } 12 void func() 13 { 14 c 阅读全文
posted @ 2021-08-08 10:35 Bytezero! 阅读(42) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <string> 3 using namespace std; 4 5 class Base 6 { 7 public: 8 Base() 9 { 10 cout << "Base的构造函数!" << endl; 11 } 12 ~B 阅读全文
posted @ 2021-08-08 10:11 Bytezero! 阅读(53) 评论(0) 推荐(0) 编辑
摘要: 1 //继承方式 2 //语法:class 子类 :继承方式 父类 3 //继承方式 三种: 4 //1.公共继承 5 //2.保护继承 6 //3.私有继承 7 8 /* 9 #include <iostream> 10 #include <string> 11 using namespace s 阅读全文
posted @ 2021-08-08 09:42 Bytezero! 阅读(56) 评论(0) 推荐(0) 编辑
摘要: 1 //继承方式 2 //语法:class 子类 :继承方式 父类 3 //继承方式 三种: 4 //1.公共继承 5 //2.保护继承 6 //3.私有继承 7 8 #include <iostream> 9 #include <string> 10 using namespace std; 11 阅读全文
posted @ 2021-08-08 09:07 Bytezero! 阅读(269) 评论(0) 推荐(0) 编辑
上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 32 下一页