随笔分类 - C++
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 void main1() 8 { 9 //精确匹配 10 //regex reg("1234"); 11 //匹配四个数字 12 //regex reg("\\d{4}")...
阅读全文
摘要:1 #include 2 3 using namespace std; 4 5 //命名空间 6 namespace smart_point 7 { 8 //智能指针计数类 9 class smart_count 10 { 11 public: 12 //构造函数 13 ...
阅读全文
摘要:Node.h 1 #pragma once 2 3 template<class T> 4 class Node 5 { 6 public: 7 T t; 8 Node *pNext; 9 10 }; forwart_list.h 1 #pragma once 2 #include "Node.h"
阅读全文
摘要:myvector.h 1 #pragma once 2 #include <initializer_list> 3 #include <iostream> 4 using namespace std; 5 6 template<class T> 7 class myvector 8 { 9 publ
阅读全文
摘要:string.h 1 #pragma once 2 #include <string> 3 #include <cstdlib> 4 #include <functional> 5 using namespace std; 6 7 class outofrange 8 { 9 10 }; 11 12
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 class mythread :public thread 8 { 9 public: 10 mythread() :thread() 11 { 12 13 } 14 15 //class 模...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 void run() 8 { 9 MessageBox(0, L"hello", L"hello", 0); 10 } 11 12 void runA(const wchar_t *s, const wchar_t *...
阅读全文
摘要:1 #include 2 using namespace std; 3 4 //错误模板类 5 template 6 class error 7 { 8 T t; 9 public: 10 void showerror() 11 { 12 cout 24 class print3d 25 { 26 pu...
阅读全文
摘要:1 #include 2 3 #include 4 using namespace std; 5 ////非安全退出,结束进程, 6 //C++ 必须释放对象,最后结束,安全退出 7 8 class pstr 9 { 10 int *p; 11 public: 12 pstr() 13 { 14 cout << "构造" << end...
阅读全文
摘要:1 #include 2 #include 3 using namespace std; 4 5 //继承自带的异常 6 class sizeerror :public exception 7 { 8 public: 9 sizeerror() :exception("尺寸大小异常") 10 { 11 12 } 13 14 const ...
阅读全文
摘要:1 #include 2 using namespace std; 3 4 //纯虚类 5 class error 6 { 7 public: 8 //纯虚函数 9 virtual void showerror() = 0; 10 }; 11 12 class big :public error 13 { 14 public: 15 void sh...
阅读全文
摘要:1 #include 2 using namespace std; 3 4 //如果产生继承,子类的对象也可以被父类捕获.因为子类内部包含父类对象 5 class outerror 6 { 7 public: 8 }; 9 10 class newerror:public outerror 11 { 12 public: 13 }; 14 15 class myclas...
阅读全文
摘要:异常类 1 #pragma once 2 #include <initializer_list> 3 using namespace std; 4 5 class memerror 6 { 7 }; 8 9 class outerror 10 { 11 }; 12 13 class safeinta
阅读全文
摘要:1 #include 2 using namespace std; 3 4 //try尝试执行,抛出throw,throw之后语句不再执行 5 //catch处理throw的异常 6 7 void main() 8 { 9 float fl1, fl2; 10 cin >> fl1 >> fl2; 11 12 //尝试执行,抛出类型检测 13 ...
阅读全文
摘要:1 #include 2 using namespace std; 3 4 //try尝试执行,抛出throw,throw之后语句不再执行 5 //catch处理throw的异常 6 7 void main() 8 { 9 float fl1, fl2; 10 cin >> fl1 >> fl2; 11 12 //尝试执行,抛出类型检测 13 ...
阅读全文
摘要:C++ 11中的Lambda表达式用于定义并创建匿名的函数对象,以简化编程工作。Lambda的语法形式如下:[函数对象参数](操作符重载函数参数) mutable或exception声明->返回值类型{ 函数体 } 可以看到,Lambda主要分为五个部分:[函数对象参数]、(操作符重载函数参数)、m
阅读全文
摘要:1 #include 2 using namespace std; 3 4 class myit 5 { 6 public: 7 static int num; 8 9 class itit 10 { 11 12 }; 13 }; 14 15 int myit::num = 0; 16 17 template 18 class my...
阅读全文

浙公网安备 33010602011771号