随笔分类 - C++
摘要:1 #include 2 using namespace std; 3 4 //拷贝构造,构造,析构,赋值重载 5 //C++会给每个类生成四个函数,写了新函数会覆盖 6 class myclass 7 { 8 public: 9 //不允许拷贝构造 10 myclass(const myclass &my) = delete; 11 //mycla...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 class myclass 8 { 9 public: 10 myclass() 11 { 12 cout my;//分配器 28 myclass *p = my.allocate(1)...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 using namespace std::placeholders; 8 9 class myclass 10 { 11 public: 12 int get(int data) 13 { 1...
阅读全文
摘要:1 #include 2 #include 3 using namespace std; 4 5 void main() 6 { 7 cout ::max() ::min() << endl; 9 cin.get(); 10 }
阅读全文
摘要:1 #include 2 using namespace std; 3 4 //异常与错误不一样,异常一般能正常工作 5 //错误就是程序无法正常工作,无法编译 6 //异常让程序在错误的输入,文件不存在,内存异常仍然可以正常工作 7 8 int divv(int a, int b) 9 { 10 try 11 { 12 if (b == ...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 9 //vector g_all; 10 //创建list存放数据 11 list g_all; 12 13 //统计共有多少数据 14 int i = 0; 15 16 /...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 9 void main() 10 { 11 ifstream fin("F:\\大数据\\大数据相关数据\\kaifang.txt"); 12 ofstream fou...
阅读全文
摘要:前提是要包含头文件 判断是否是左值引用 是否是右值引用 是否是数组 是否是一个整数 是否是一个类 1 check(1, 10); 2 int i(10); 3 int &ri(i); 4 int &&rri(i + 3); 5 //判断是否是左值引用 0不是 1是 6 cout << is_lval
阅读全文
摘要:regex_match 整个字符串是否匹配 (通过cmatch存储匹配的结果),match[0]代表整个匹配序列,match[1]代表第1个匹配后的子序列,match[2]代表第2个匹配后的子序列 代码示例: regex_search 整个字符串进行查找判断是否含有指定数据类型 regex_repl
阅读全文
摘要:正则表达式是什么? 字符是计算机软件处理文字最基本的单位,可以是字母,也可以是数字,标点符号,空格,换行符,汉字等等. 字符串是0个或更多个字符的序列.文本也就是文字,字符串.说某个字符串匹配某个正则表达式,通常是指这个字符串里有一部分(或几部分分别)能满足表达式给出的条件. 我们在处理字符串的程序
阅读全文
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 6 7 8 void main() 9 { 10 //string str("\"C:\\Program Files (x86)\\Tencent\\QQ\\Bin\\QQScLauncher.exe\""); 11 //\n不会换行,...
阅读全文
摘要:1 #include 2 #include 3 using namespace std; 4 using namespace std::placeholders; 5 6 int add(int a, int b) 7 { 8 return a + b; 9 } 10 11 class myclass 12 { 13 public: 14 int ope...
阅读全文
摘要:1 #include 2 using namespace std; 3 4 //模板自动匹配*多的 5 template 6 void com(T *p) 7 { 8 cout 13 void com(T **p) 14 { 15 cout << "**" << endl; 16 cout << typeid(T).name() << endl; ...
阅读全文
摘要:1 #include 2 using namespace std; 3 4 //模板可以设置有默认值 5 template 6 void hello(T str) 7 { 8 cout 14 void show(T1 t1 = 1, T2 t2 = 2, T3 t3 = 3) 15 { 16 cout ("hello"); 24 show(); 2...
阅读全文
摘要:1 #include 2 #include 3 using namespace std; 4 using namespace std::placeholders; 5 6 class myclass 7 { 8 public: 9 void add1(int a) 10 { 11 cout << a << endl; 12 } 13...
阅读全文
摘要:1 #include 2 using namespace std; 3 4 template 5 void go(T t1) 6 { 7 cout 11 void go(T *t1) 12 { 13 cout << "******" << endl; 14 } 15 16 void main() 17 { 18 int *p = new int[2]...
阅读全文
摘要:1 #include 2 using namespace std; 3 4 //ref 在模板中变量转化为引用 5 //move 左值引用转化为右值引用 6 //副本,不能改变数据 7 template 8 void print1(T t) 9 { 10 t += 1; 11 cout 15 void print2(T &t) 16 { 17 t...
阅读全文
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 6 //传递模板进去自动确定模板的元素类型 7 template 8 void showall(vector v,list l) 9 { 10 for (auto i : v) 11 { 12 cout myint{ 1,...
阅读全文
摘要:1 #include 2 #include 3 using namespace std; 4 using std::function; 5 6 int add(int a, int b) 7 { 8 return a + b; 9 } 10 11 template 12 T run(T t1, T t2, F f) 13 { 14 return f(t...
阅读全文
摘要:1 #include 2 using namespace std; 3 4 template 5 void show(T t) 6 { 7 cout << t << endl; 8 t += 10; 9 } 10 11 void main() 12 { 13 double db(1.0); 14 double &ldb(db); 15 ...
阅读全文

浙公网安备 33010602011771号