随笔分类 -  C++

摘要:设计模式六大原则: (1)单一职责原则——一个类只有一个职责; (2)里氏替换原则——体现在继承多态,子类无意间的成员函数覆盖父类的成员函数; (3)依赖倒置原则——高层模块依赖抽象类、低层模块依赖抽象类(高层模块不能直接依赖低层模块);细节(实体类)依赖于抽象,而非抽象依赖于细节; (4)接口隔离 阅读全文
posted @ 2021-02-05 18:40 撑死算工伤吗 阅读(82) 评论(0) 推荐(0)
摘要:QT5.6.1下C++的char/string跟int型数据大小比较 int a = 1; char c = '1'; string s = "1"; //01string和int型比较——c_str + atoi if(a == (atoi(s.c_str()))) { cout << "a = 阅读全文
posted @ 2021-02-02 20:00 撑死算工伤吗 阅读(246) 评论(0) 推荐(0)
摘要:以下是代码: class Identity{ public: string m_Name;//姓名 string m_Pwd;//密码 virtual void showSubMenu();//不同身份的子菜单 }; class Student{ public: virtual void showS 阅读全文
posted @ 2021-02-01 14:35 撑死算工伤吗 阅读(177) 评论(0) 推荐(0)
摘要:代码如下: class SpeehManager { public: vector<vector<int>> vec; SpeechManager{ vector<int> v1; vector<int> v2; vector<int> v3; this->vec.push_back(v1); th 阅读全文
posted @ 2021-01-30 16:02 撑死算工伤吗 阅读(22309) 评论(0) 推荐(1)
摘要:代码如下: class SpeechManager { public: vector<vector<int>> vec; //保存第一轮、第二轮、决赛选手编号 map<int, Speaker> m_Speaker; //所有选手信息-编号+选手类 vector<int> m_RandomV; // 阅读全文
posted @ 2021-01-30 15:50 撑死算工伤吗 阅读(1622) 评论(0) 推荐(0)
摘要:从CSV文件中读取数据代码: bool speechManager::fileIsEmpty() { //创建文件流 ofstream ifs(FILENAME, ios::in); //判断文件是否打开成功 if(!ifs.is_open()) { cout << "open false" << 阅读全文
posted @ 2021-01-27 10:23 撑死算工伤吗 阅读(7472) 评论(0) 推荐(0)
摘要:前提: 用内置函数对象find测试查找自定义数据类型Person 代码: class Person{ public: string m_Name; int m_Age; Person(string name, int age) { this->m_Name = name; this->m_Age = 阅读全文
posted @ 2021-01-25 12:15 撑死算工伤吗 阅读(9705) 评论(0) 推荐(0)
摘要:代码如下: #include <iostream> #include <map> #include <string> #include <ctime> #define MAX 10 using namespace std; class Employee{ public: string m_Name; 阅读全文
posted @ 2021-01-24 15:35 撑死算工伤吗 阅读(327) 评论(0) 推荐(0)
摘要:以下是代码: #include <iostream> #include <string> #include <typeinfo> #include <vector> #include <deque> #include <list> #include <set> #include <map> #inc 阅读全文
posted @ 2021-01-23 17:42 撑死算工伤吗 阅读(1701) 评论(1) 推荐(0)
摘要:编译时出现“void value not ignored as it ought to be”错误,原因是因为,一个函数的返回值为void,但是你又把这个函数的返回值赋值给了一个具体类型的变量。 注意函数声明和函数实现的返回值要一致; 或者函数返回值为void,就不要再返回任何东西了。 阅读全文
posted @ 2021-01-11 18:05 撑死算工伤吗 阅读(2950) 评论(0) 推荐(0)
摘要:将QT库添加到系统变量 Qt Creator编译的程序,在其工程文件夹下会有一个debug文件夹,其中有程序的.exe可执行文件。但Qt Creator默认是用动态链接的,就是可执行程序在运行时需要相应的.dll文件。我们点击生成的.exe文件,首先可能显示“没有找到mingwm10.dll,因此这 阅读全文
posted @ 2021-01-10 19:54 撑死算工伤吗 阅读(2627) 评论(0) 推荐(0)