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! 阅读(142) 评论(0) 推荐(0)
摘要: 1 //多态 2 //静态多态:函数重载 和 运算符重载 属于静态多态 ,复用函数名 3 //动态多态:派生类和虚函数实现运行时多态 4 5 //静态多态和动态多态的区别 6 //静态多态的函数地址早绑定 - 编译阶段确定函数地址 7 //动态多态的函数地址晚绑定 - 运行阶段确定函数地址 8 9 阅读全文
posted @ 2021-08-08 16:21 Bytezero! 阅读(225) 评论(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! 阅读(62) 评论(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! 阅读(1152) 评论(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! 阅读(92) 评论(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! 阅读(67) 评论(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! 阅读(77) 评论(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! 阅读(90) 评论(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! 阅读(297) 评论(0) 推荐(0)
摘要: 1 //C++ 继承 2 //继承是面向对象三大特性之一 3 4 #include <iostream> 5 #include <string> 6 using namespace std; 7 8 //普通实现页面****************************************** 阅读全文
posted @ 2021-08-08 08:37 Bytezero! 阅读(57) 评论(0) 推荐(0)