随笔分类 -  重学C++

摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; #include<vector> void pv(vector<int> & v) { for(vector<int>::iterator it=v 阅读全文
posted @ 2021-04-23 12:51 yub4by 阅读(124) 评论(0) 推荐(0) 编辑
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; void test1() { string str = "hello"; cout << str << endl; //read for(int i 阅读全文
posted @ 2021-04-23 11:13 yub4by 阅读(98) 评论(0) 推荐(0) 编辑
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 3.1.6 string字符串比较 字符串比较是按字符的ASCII码进行对比 = 返回 0 > 返回 1 < 返回 -1 int compar 阅读全文
posted @ 2021-04-22 22:06 yub4by 阅读(169) 评论(0) 推荐(0) 编辑
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 3.1.5 string查找和替换 int find(const string& str, int pos = 0) const; //查找s 阅读全文
posted @ 2021-04-22 22:06 yub4by 阅读(80) 评论(0) 推荐(0) 编辑
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 3.1.4 string字符串拼接 string& operator+=(const char* str); //重载+=操作符 string 阅读全文
posted @ 2021-04-22 22:05 yub4by 阅读(133) 评论(0) 推荐(0) 编辑
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 3.1.3 string赋值操作 string& operator=(const char* s); //char*类型字符串 赋值给当前的字 阅读全文
posted @ 2021-04-22 22:04 yub4by 阅读(179) 评论(0) 推荐(0) 编辑
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 3.1 string容器 3.1.1 string基本概念 string和char * 区别: char * 是一个指针 string是c++ 阅读全文
posted @ 2021-04-22 22:02 yub4by 阅读(132) 评论(0) 推荐(0) 编辑
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; #include <vector> #include <algorithm> /* 2.5.3 vector容器嵌套容器 */ void test1 阅读全文
posted @ 2021-04-22 20:47 yub4by 阅读(134) 评论(0) 推荐(0) 编辑
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; #include<vector> #include<algorithm> /* 2.5.2 vector容器存放自定义数据类型 */ class P 阅读全文
posted @ 2021-04-22 20:45 yub4by 阅读(162) 评论(0) 推荐(0) 编辑
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; #include<vector> #include<algorithm> /* 2.5.1 vector放置内置数据类型 容器: vector 算法 阅读全文
posted @ 2021-04-22 20:44 yub4by 阅读(65) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2021-04-22 19:44 yub4by 阅读(40) 评论(0) 推荐(0) 编辑
摘要:MyArray.hpp #pragma once #include<iostream> #include<string> using namespace std; template<class T> class MyArray { public: // 有参构造 MyArray(int capaci 阅读全文
posted @ 2021-04-18 14:20 yub4by 阅读(132) 评论(0) 推荐(0) 编辑
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 1.3.8类模板与友元 掌握类模板配合友元函数的类内和类外实现 全局函数类内实现 - 直接在类内声明友元即可 全局函数类外实现 - 需要提前让 阅读全文
posted @ 2021-04-18 14:16 yub4by 阅读(49) 评论(0) 推荐(0) 编辑
摘要:person.h #pragma once #include<iostream> #include<string> using namespace std; template<class T1, class T2> class Person{ public: T1 name; T2 age; Per 阅读全文
posted @ 2021-04-18 14:15 yub4by 阅读(65) 评论(0) 推荐(0) 编辑
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; #include<typeinfo> /* 1.3.6类模板成员函数类外实现 */ template<class T1, class T2> cla 阅读全文
posted @ 2021-04-18 14:12 yub4by 阅读(57) 评论(0) 推荐(0) 编辑
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; #include<typeinfo> /* 1.3.5类模板与继承 当子类继承的父类是一个类模板时,子类在声明的时候,要指定出父类中T的类型 如果不 阅读全文
posted @ 2021-04-18 14:11 yub4by 阅读(80) 评论(0) 推荐(0) 编辑
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; #include<typeinfo> /* 1.3.4类模板对象做函数参数 类模板实例化出的对象,向函数传参的方式 共有三种传入方式: 1. 指定传 阅读全文
posted @ 2021-04-18 11:19 yub4by 阅读(54) 评论(0) 推荐(0) 编辑
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 1.3.3类模板中成员函数创建时机 类模板中成员函数和普通类中成员函数创建时机是有区别的: 普通类中的成员函数一开始就可以创建 类模板中的成员 阅读全文
posted @ 2021-04-17 21:19 yub4by 阅读(65) 评论(0) 推荐(0) 编辑
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 1.3.2类模板和模板函数的区别 1. 类模板没有自动类型推导的使用方式 2. 类模板在模板参数列表中可以有默认参数(函数模板不可以有默认) 阅读全文
posted @ 2021-04-17 21:18 yub4by 阅读(83) 评论(0) 推荐(0) 编辑
摘要:#include<iostream> #include<stdlib.h> #include<string> using namespace std; /* 1.3类模板 1.3.1类模板语法 作用:建立一个通用类,类中的成员 数据类型可以不具体制定,用一个虚拟的类型来代表 语法:template< 阅读全文
posted @ 2021-04-17 20:09 yub4by 阅读(63) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示