![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
语法
小白o菜
Stay hungry, stay foolish!
展开
-
容器里存放数组 关于内存问题
要小心在函数里网容器里加东西,因为会自动释放 #include <iostream> #include <vector> using namespace std; vector<int *> arr; void fun() { int a[] = {1,2,3}; for(int i = 0 ;i< 1 ;i++) arr.push_back(a); //这里会自动释放,所有存在arr里的要用new // int *p = new int[3];原创 2020-11-03 21:20:53 · 252 阅读 · 0 评论 -
vector容器三种遍历方法
vector容器三种遍历方法 int main() { int tank, bottle_1, bottle_2; tank = 10, bottle_1 = 3, bottle_2 = 7; //cin >> tank >> bottle_1 >> bottle_2; int* p = new int[3]();//10个值初始化为0的int *p = tank; *(p + 1) = bottle_1; *(p + 2) = bottle_2; arr原创 2020-11-03 20:30:46 · 861 阅读 · 0 评论