vector
NNNNatsu
自学CPP,博客作为笔记本使用
展开
-
观测Vector容器开辟内存次数
#include <iostream> #include <vector> #include <ctime> using namespace std; /* 监测vector开辟内存次数 */ void test() { srand((unsigned int)time(NULL)); vector<int>v; int num = 1;//计数器 int* p = NULL; for (int a = 0; a < 92223; .原创 2020-10-14 00:10:11 · 129 阅读 · 0 评论 -
黑马C++基础练习《员工分类》采用 multimap&vector容器
项目要求: 1:创建若干员工,赋初值。 2:为每位员工分配相应的岗位。 3:按照岗位分批输出人员信息。 项目思路: 创建员工类,并采用vector容器存储员工信息。由于multimap可以存储同一key值,故采用该容器。 遍历vector容器析出*it(员工对象),并对其赋值(部门值) for(vector<Person>::iterator it = v.begin(); it != v.end(); it ++) { //multimap<int,Person&原创 2020-10-05 10:21:14 · 210 阅读 · 0 评论