12 2019 档案

摘要:#include <iostream> #include <string> #include <stack> // https://zh.cppreference.com/w/cpp/container/stack // std::stack 类是容器适配器,它给予程序员栈的功能——特别是 FILO (先进后出)数据结构。 // 该类模板表现为底层容器的包装器——只提供特定函数集合。栈从被称作栈顶 阅读全文
posted @ 2019-12-22 16:19 路边的十元钱硬币 阅读(1900) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <string> #include <deque> // https://zh.cppreference.com/w/cpp/container/deque // vector 和 deque 的差别 // https://www.cnblogs.com/zhuyf87/archive/2012/12/09/2809896.html usi 阅读全文
posted @ 2019-12-22 15:58 路边的十元钱硬币 阅读(1082) 评论(0) 推荐(0) 编辑
摘要:主要差别: list 是双向链表,forward_list 是双向链表。 成员函数差异: * forward_list 中设计的一系列 xxx_after() 的原因: 其中的元素仅知道后面的元素,不知道前面的元素。(单向链表的特性)所以类似于 insert 这样的操作,需要指定前一个元素的迭代器, 阅读全文
posted @ 2019-12-21 11:01 路边的十元钱硬币 阅读(1636) 评论(1) 推荐(0) 编辑
摘要:#include <iostream> #include <string> #include <forward_list> using namespace std; // https://zh.cppreference.com/w/cpp/container/forward_list std::ostream& operator<<(std::ostream& ostr, const std::f 阅读全文
posted @ 2019-12-15 21:11 路边的十元钱硬币 阅读(1401) 评论(0) 推荐(0) 编辑
摘要:* std::list 是支持常数时间从容器任何位置插入和移除元素的容器。不支持快速随机访问。它通常实现为双向链表。与 std::forward_list 相比,此容器提供双向迭代但在空间上效率稍低。 阅读全文
posted @ 2019-12-15 15:14 路边的十元钱硬币 阅读(17133) 评论(0) 推荐(0) 编辑
摘要:#include #include #include using namespace std; // https://zh.cppreference.com/w/cpp/container/array int main() { ///array arr({ 1,2,3 }); // 非法 array arr1{ { 1,2,3 } }; // 不可以扩容,属于固定大小的数组。... 阅读全文
posted @ 2019-12-15 10:04 路边的十元钱硬币 阅读(8354) 评论(0) 推荐(1) 编辑
摘要:#include #include using namespace std; int main() { int ar[10] = { 1,2,3,4,5,6,7,8,9,0 }; std::vector vec5(ar, ar + 10); // reverse size_t cap1 = vec5.capacity(); // = 10 vec5.reserve(20)... 阅读全文
posted @ 2019-12-12 23:06 路边的十元钱硬币 阅读(1141) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <vector> #include <chrono> #include <windows.h> using namespace std; using namespace std::chrono; // 要考虑 copy ctor 和 copy 阅读全文
posted @ 2019-12-12 22:09 路边的十元钱硬币 阅读(392) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <vector> using namespace std; int main() { // 初始化的方式 std::vector<int> vec1; //std::vector<int> vec2(1750000);// 7G std::v 阅读全文
posted @ 2019-12-11 22:30 路边的十元钱硬币 阅读(5595) 评论(0) 推荐(0) 编辑
摘要:#include // operator Type() 类型操作符重载 // operator int() // operator double() // ... ////////////////////////////////////////////////////////// class Rectangle { public: #ifdef Want_compiler_to_add_... 阅读全文
posted @ 2019-12-02 19:33 路边的十元钱硬币 阅读(246) 评论(0) 推荐(0) 编辑
摘要:#include // operator Type() 类型操作符重载 // operator int() // operator double() // ... ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(const int w, cons... 阅读全文
posted @ 2019-12-02 19:22 路边的十元钱硬币 阅读(750) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> // 可变模板参数 // 此例:可以构造可变数量,可变类型的函数输入。 // 摘自:https://www.cnblogs.com/qicosmos/p/4325949.html ///////////////////////////// using namespace std; //递归终止函数 void print() { cout << "empty" 阅读全文
posted @ 2019-12-01 21:21 路边的十元钱硬币 阅读(578) 评论(0) 推荐(0) 编辑
摘要:#include // 可变模板参数 // 此例:可以构造可变数量,可变类型的函数输入。 // 摘自:https://www.cnblogs.com/qicosmos/p/4325949.html ///////////////////////////// using namespace std; //递归终止函数 void print() { cout void print(T h... 阅读全文
posted @ 2019-12-01 21:16 路边的十元钱硬币 阅读(844) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> // overloading "operator >> " outside class // >> 应该定义在类之外。 ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(int w, int h) : width(w), 阅读全文
posted @ 2019-12-01 16:27 路边的十元钱硬币 阅读(292) 评论(0) 推荐(0) 编辑
摘要:虚函数的几点说明: 1. 当一个成员函数定义为虚函数时,其派生类中的同名函数也自动为虚函数。无论其是否添加了 virtual 关键字。 为了能良好的阅读代码,请加上。 2. 父类的虚函数,就是为了让子类中的同名成员函数覆盖。这样,父类对象的指针就可以指向子类对象,并调用子类的同名函数。 3. 纯虚函 阅读全文
posted @ 2019-12-01 15:42 路边的十元钱硬币 阅读(228) 评论(0) 推荐(0) 编辑
摘要:Stack 堆 存在于某作用域内的一块空间。说白了就是函数产生的空间,用于存放函数的变量、返回地址。 在函数体中声明的局部变量,就时存储在Stack中。 Heap 栈 由操作系统提供的全局空间。在程序结束后由系统释放。 定义的全局变量就在这个内存区域中。 静态数据区 static对象所在区域。 文字 阅读全文
posted @ 2019-12-01 15:27 路边的十元钱硬币 阅读(90) 评论(0) 推荐(0) 编辑
摘要:类中含有 指针类型 的成员变量时,就必须要定义 copy ctor 和 copy op= copy ctor 请见: copy op= 请见: https://www.cnblogs.com/alexYuin/p/11965172.html 阅读全文
posted @ 2019-12-01 15:13 路边的十元钱硬币 阅读(337) 评论(0) 推荐(0) 编辑
摘要:使用示例 阅读全文
posted @ 2019-12-01 15:02 路边的十元钱硬币 阅读(1205) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> // overloading "operator + " // 要考虑加法的形式 // a+1 // a+a // 1+a ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(const int w, const int 阅读全文
posted @ 2019-12-01 14:33 路边的十元钱硬币 阅读(300) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> // overloading "operator () " outside class ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(const int w, const int h) : width(w), hei 阅读全文
posted @ 2019-12-01 14:16 路边的十元钱硬币 阅读(232) 评论(0) 推荐(0) 编辑
摘要:#include // overloading "operator [] " inside class ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(const int w, const int h) : width(w), height... 阅读全文
posted @ 2019-12-01 12:51 路边的十元钱硬币 阅读(212) 评论(0) 推荐(0) 编辑
摘要:++i,应该是先自加一,返回自身(已经加1之后的自身); i++,应该是先拷贝自身,再自加一,返回自身的拷贝(自己已经加1,但是拷贝没有)。 阅读全文
posted @ 2019-12-01 12:43 路边的十元钱硬币 阅读(265) 评论(0) 推荐(0) 编辑
摘要:++i,应该是先自加一,返回自身(已经加1之后的自身); i++,应该是先拷贝自身,再自加一,返回自身的拷贝(自己已经加1,但是拷贝没有)。 阅读全文
posted @ 2019-12-01 11:32 路边的十元钱硬币 阅读(675) 评论(0) 推荐(0) 编辑
摘要:#include // overloading "operator << " outside class // << 应该定义在类之外。 ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(int w, int h) : width(w), h... 阅读全文
posted @ 2019-12-01 10:22 路边的十元钱硬币 阅读(385) 评论(0) 推荐(0) 编辑
摘要:#include // overloading "operator = " outside class // 是二元操作符 ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(int w, int h) : width(w), height(... 阅读全文
posted @ 2019-12-01 10:01 路边的十元钱硬币 阅读(4050) 评论(0) 推荐(0) 编辑
摘要:#include // overloading "operator = " inside class // = 是一元操作符。不写,编译器会提供 默认 拷贝赋值函数。可以通过显式“=delete”来禁用默认。对于复杂class的默认=可能会造成问题,请特别注意。 ////////////////////////////////////////////////////////// clas... 阅读全文
posted @ 2019-12-01 09:44 路边的十元钱硬币 阅读(501) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> // overloading "operator == " outside class // == 是二元操作符 ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(int w, int h) : width(w), he 阅读全文
posted @ 2019-12-01 09:29 路边的十元钱硬币 阅读(325) 评论(0) 推荐(0) 编辑
摘要:#include // overloading "operator == " inside class // == 是二元操作符 ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(int w, int h) : width(w), heig... 阅读全文
posted @ 2019-12-01 09:25 路边的十元钱硬币 阅读(1148) 评论(0) 推荐(0) 编辑

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