摘要:
#include<iostream> using namespace std; #include<stack> #include<string> #include<list> //list容器 排序案例 对于自定义数据类型 做排序 //按照年龄进行升序,如果年龄相同按照身高进行降序 class Pe
阅读全文
posted @ 2021-12-03 15:19
keep码
阅读(573)
推荐(0)
摘要:
#include<iostream> #include<string> #include<vector> #include<algorithm>//标准算法头文件 using namespace std; //vector容器存放内置数据类型 void myPrint(int val) { cout
阅读全文
posted @ 2021-11-25 21:25
keep码
阅读(22)
推荐(0)
摘要:
#include<iostream> #include<string> using namespace std; //实现通用 对数组进行排序的函数 //规则 从大到小 //算法 选择 //测试 char 数组、int数组 //交换函数模板 template<class T> void mySwap
阅读全文
posted @ 2021-11-22 16:15
keep码
阅读(133)
推荐(0)
摘要:
#include <iostream> using namespace std; #include <string> //多态案例 电脑组装 //抽象不同零件类 //抽象CPU类 class CPU { public: //抽象的计算函数 virtual void calculate() = 0;
阅读全文
posted @ 2021-11-20 17:52
keep码
阅读(66)
推荐(0)
摘要:
多态 #include <iostream> using namespace std; #include <string> //多态 //动物类 class Animal { public: //虚函数 virtual void speak() { cout << "动物在说话" << endl;
阅读全文
posted @ 2021-11-19 16:23
keep码
阅读(76)
推荐(0)
摘要:
#include <iostream> using namespace std; #include <string> //继承方式 //公共继承 class Basel { public: int m_A; protected: int m_B; private: int m_C; }; class
阅读全文
posted @ 2021-11-18 16:48
keep码
阅读(105)
推荐(0)
摘要:
#include <iostream> using namespace std; #include <string> class Person { public: Person(int age) { //1、当形参和成员变量同名时,可用this指针来区分 this->age = age; } Per
阅读全文
posted @ 2021-11-15 22:11
keep码
阅读(26)
推荐(0)
摘要:
静态成员变量 #include <iostream> using namespace std; #include <string> class Person { public: static int m_A;//静态成员变量 //静态成员变量特点: //1 在编译阶段分配内存 //2 类内声明,类外
阅读全文
posted @ 2021-11-15 11:58
keep码
阅读(31)
推荐(0)
摘要:
#include <iostream> using namespace std; #include <string> class Phone { public: Phone(string name) { m_PhoneName = name; cout << "Phone构造" << endl; }
阅读全文
posted @ 2021-11-14 23:18
keep码
阅读(111)
推荐(0)
摘要:
#include <iostream> using namespace std; #include <string> class Person { public: //传统方式初始化 //Person(int a, int b, int c){ //m_A = a; //m_B = b; //m_C
阅读全文
posted @ 2021-11-14 22:34
keep码
阅读(35)
推荐(0)