摘要: 一、 基类的指针指向派生类的,运行基类的相关函数变量。 #include<bits/stdc++.h> using namespace std; class base{ public: int a = 1; void test(){ cout<<"base"<<endl; } }; class ge 阅读全文
posted @ 2021-12-05 19:47 wanghai673 阅读(32) 评论(0) 推荐(0)
摘要: 一、 继承与派生的基本概念 #include<bits/stdc++.h> using namespace std; class Student{ private: string name; char sex; int height,weight; public: Student(string _n 阅读全文
posted @ 2021-12-01 17:17 wanghai673 阅读(38) 评论(0) 推荐(0)
摘要: 1、容器都用模板函数 class cmp{ public: bool operator()(edge &a,edge &b){ return a.c>b.c; } }; View Code 2、算法 阅读全文
posted @ 2021-11-27 14:33 wanghai673 阅读(33) 评论(0) 推荐(0)
摘要: 一、C++11 新特性(1) 1、 任何容器的初始化 = {1,12,4124,124} 2、 auto关键字 decltype(1) a = 5; 3、 #include<memory> shared_ptr #include<bits/stdc++.h> using namespace std; 阅读全文
posted @ 2021-11-24 14:39 wanghai673 阅读(37) 评论(0) 推荐(0)
摘要: 1、string讲义 程序设计与算法(三)C++面向对象程序设计_中国大学MOOC(慕课) (icourse163.org) 相关重点 1、赋值相关操作 2、字典序比较 < > == 均可用 3、分割子串 4、寻找字符串返回第一个位置 5、寻找第一个出现的字符 以上相关string类 二、STL相关 阅读全文
posted @ 2021-11-08 21:01 wanghai673 阅读(42) 评论(0) 推荐(0)
摘要: 1、 运算符重载 #include<bits/stdc++.h> using namespace std; class Complex{ public: double r,i; Complex(double rr = 0,double ii = 0):r(rr),i(ii){} Complex op 阅读全文
posted @ 2021-11-02 16:48 wanghai673 阅读(29) 评论(0) 推荐(0)
摘要: 1、cerr freopen cout输出到文件内时,cerr能输出到控制台显示 2、cin.getline() defalut -> '\n' #define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #include<bits 阅读全文
posted @ 2021-10-23 10:25 wanghai673 阅读(37) 评论(0) 推荐(0)
摘要: 1、this指针的运用 指向当前函数作用类的指针 相当于翻译为C语言,r.run() = run(test * this) #include<bits/stdc++.h> using namespace std; class test{ private: double real,imag; publ 阅读全文
posted @ 2021-10-20 17:19 wanghai673 阅读(49) 评论(0) 推荐(0)
摘要: 1、 成员函数可写在类的外面 #include<bits/stdc++.h> using namespace std; class student{ public: int grade; string name; void init_(string _name,int _grade){ name = 阅读全文
posted @ 2021-10-07 12:51 wanghai673 阅读(39) 评论(0) 推荐(0)
摘要: 1、引用 #include<bits/stdc++.h> using namespace std; void swap(int &a,int &b){ int temp = a; a = b; b = temp; } void swap(int *a,int *b){ int temp = *a; 阅读全文
posted @ 2021-10-05 11:26 wanghai673 阅读(31) 评论(0) 推荐(0)