随笔分类 -  c++ 练习

摘要:1 #include<iostream> 2 #include<string> 3 using namespace std; 4 5 class TextBlock{ 6 public: 7 TextBlock(string x):text(x){ 8 } 9 //operator[] for co 阅读全文
posted @ 2020-10-11 11:28 wsl96 阅读(113) 评论(0) 推荐(0)
摘要:例一: 1 #include<iostream> 2 using namespace std; 3 class numbered{ 4 private: 5 static int seq; 6 public: 7 numbered(){ mysn = seq++;} 8 int mysn; 9 }; 阅读全文
posted @ 2020-07-10 16:17 wsl96 阅读(190) 评论(0) 推荐(0)
摘要:直接管理内存:使用new和delete 1 #include<iostream> 2 #include<vector> 3 using namespace std; 4 5 vector<int>* new_vector(){ 6 //分配失败new会返回一个空指针 7 return new (no 阅读全文
posted @ 2020-06-11 22:33 wsl96 阅读(221) 评论(0) 推荐(0)