#include <iostream>
#include <vector>
using namespace std;
int main ()
{
    vector<int> foo (3,100);   // three ints with a value of 100
    vector<int> bar (5,200);   // five ints with a value of 200
    
    foo.swap(bar);
    
    cout << "foo contains:";
    for (unsigned i=0; i<foo.size(); i++)
        cout << ' ' << foo[i];
    cout << '\n';
    
    cout << "bar contains:";
    for (unsigned i=0; i<bar.size(); i++)
        cout << ' ' << bar[i];
    cout << '\n';
    
    return 0;
}

 

相关文章:

  • 2021-05-18
  • 2021-12-06
  • 2022-02-11
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-13
  • 2022-12-23
  • 2021-09-03
  • 2021-09-29
  • 2021-08-18
  • 2021-12-31
  • 2022-12-23
相关资源
相似解决方案