10 2020 档案
摘要:第一种: 1 #include <iostream> 2 #include <unordered_set> 3 #include <utility> 4 #include <vector> 5 6 using namespace std; 7 8 using KEY = pair<int,int>;
阅读全文
摘要:inline:声明和定义处(类外)都可以写,建议只写在类外定义处,实现写在inl.h里include在.h文件里而不是写在.cpp或.cc; const:类内声明和类外定义都要写; virtual:只能写在类内声明处; override/final:只能写在类内声明处; explicit:只能写在类
阅读全文
摘要:1 #include <iostream> 2 #include <stdexcept> 3 4 using namespace std; 5 6 7 class Data 8 { 9 public: 10 Data(int a,int b):y(a),m(b) 11 { 12 if(b < 1 |
阅读全文
摘要:1 #include <stdio.h> 2 3 int main() 4 { 5 const int max_name = 20; // 字符数组最大长度 6 char name[max_name]; 7 8 char fmt[10]; 9 sprintf(fmt,"%%%ds",max_name
阅读全文
摘要:使用 max 比较多个数字(在c++20生效): 1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 int a = 0,b = 9,c = 9,d = 7; 8 cout << max( {a,b,c,d} ) <
阅读全文
浙公网安备 33010602011771号