⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 list7-8.cpp

📁 这是关于VC++中的STL容器的资料,包括了STL容器各个类之间关系以及类的说明
💻 CPP
字号:
// Listing 7.8
// This program demonstrates how the size(), capacity()
// and max_size() are used.  It also demonstrates how
// a container can be constructed from another container
// using the constructor or the insert() methods

#include <iostream>
#include <vector>
#include <list>

//using namespace std;

void main(void)
{

   vector<int> X;
   vector<int> Y;
   X.push_back(1);
   Y.push_back(1);
   Y.push_back(3);
   Y.push_back(5);
   Y.push_back(7);
   cout << "X size     " << X.size() << endl;
   cout << "X capacity " << X.capacity() << endl;
   cout << "X max size " << X.max_size() << endl;
   X.insert(X.begin(),Y.begin(),Y.end());
   cout << "X size     " << X.size() << endl;
   cout << "X capacity " << X.capacity() << endl;
   cout << "X max size " << X.max_size() << endl;
   cout << "Y size     " << Y.size() << endl;
   cout << "Y capacity " << Y.capacity() << endl;
   cout << "Y max size " << Y.max_size() << endl;
   vector<int> Z(Y);
   Z.insert(Z.end(),13,Y.front());
   cout << "Z size     " << Z.size() << endl;
   cout << "Z capacity " << Z.capacity() << endl;
   cout << "Z max size " << Z.max_size() << endl;



}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -