上一页 1 2 3 4 5 6 7 ··· 9 下一页
摘要: ```C++ #include <vector> void printVector(vector<int>& v) { for (vector<int>::iterator it = v.begin(); it != v.end(); it++) { cout << *it << " "; } co 阅读全文
posted @ 2021-09-26 12:12 健丽 阅读(22) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; #include<string> //string的构造函数 // //* `string(); ` //创建一个空的字符串 例如: string str; //`string(const char* s); ` //使 阅读全文
posted @ 2021-09-25 19:56 健丽 阅读(26) 评论(0) 推荐(0) 编辑
摘要: ## 2 STL初识### 2.1 STL的诞生* 长久以来,软件界一直希望建立一种可重复利用的东西* C++的**面向对象**和**泛型编程**思想,目的就是**复用性的提升*** 大多情况下,数据结构和算法都未能有一套标准,导致被迫从事大量重复工作* 为了建立数据结构和算法的一套标准,诞生了** 阅读全文
posted @ 2021-09-25 16:56 健丽 阅读(31) 评论(0) 推荐(0) 编辑
摘要: ```C++ //交换整型函数 void swapInt(int& a, int& b) { int temp = a; a = b; b = temp; } //交换浮点型函数 void swapDouble(double& a, double& b) { double temp = a; a = 阅读全文
posted @ 2021-09-24 11:16 健丽 阅读(27) 评论(0) 推荐(0) 编辑
摘要: class Animal { public: //Speak函数就是虚函数 //函数前面加上virtual关键字,变成虚函数,那么编译器在编译的时候就不能确定函数调用了。 virtual void speak() { cout << "动物在说话" << endl; } }; class Cat : 阅读全文
posted @ 2021-09-21 19:20 健丽 阅读(32) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; //普通实现页面 //Java 页面 class Java { public: void header() { cout << "首页、公开课、登录、注册>>>>(公共头部)" << endl; } void foote 阅读全文
posted @ 2021-09-21 18:04 健丽 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 加号运算符重载 运算符重载的本质是 //成员函数重载本质调用Person p3 = p1.operator+(p2);Person p3 = p1 +p2;//全局函数重载本质调用 Person p3 = operator+(p1,p2);//需注意 运算符重载 也可以发生函数重载Person p3 阅读全文
posted @ 2021-09-20 12:04 健丽 阅读(97) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> using namespace std; #include<string> //全局函数做友元 class Building{ //goodGay 全局函数是Building好朋友,可以访问Building中私有成员 friend void goodGay(B 阅读全文
posted @ 2021-09-19 19:28 健丽 阅读(56) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> using namespace std; class Person { int m_A;//非静态成员变量 属于类的对象上的 static int m_B;//静态成员变量 不属于类的对象上 void func(){}//非静态成员函数 static void 阅读全文
posted @ 2021-09-19 11:53 健丽 阅读(25) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> using namespace std; #include <string> //对象的初始化和清理 //1、构造函数 进行初始化操作 class Person { public: //1.1 构造函数 //没有返回值 不同写void //函数名 与类名相同 阅读全文
posted @ 2021-09-19 10:36 健丽 阅读(39) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 9 下一页