일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- C
- beans
- c++
- 투자
- CLASS
- Kafka
- UTF-8
- CSS
- Sort
- 노드
- query
- 자료구조
- algorithm
- API
- Call-by-reference
- jsp
- java
- function
- WebProgramming
- System
- OOP
- request
- HTML
- 포인터
- meta
- 윈도우즈
- array
- 악성코드
- JavaScript
- windows
- Today
- Total
hahahia
Vector assign 본문
#include <vector>
#include <iostream>
using namespace std;
void main( )
{
vector<int> v1, v2, v3;
vector<int>::iterator iter;
v1.push_back(10);
v1.push_back(20);
v1.push_back(30);
v1.push_back(40);
v1.push_back(50);
cout << "v1 = " ;
for (iter = v1.begin(); iter != v1.end(); iter++)
cout << *iter << " ";
cout << endl;
v2.assign(v1.begin(), v1.end()); // 할당
cout << "v2 = ";
for (iter = v2.begin(); iter != v2.end(); iter++)
cout << *iter << " ";
cout << endl;
v3.assign(7, 4); // 벡터의 크기, 원소의 값
cout << "v3 = ";
for (iter = v3.begin(); iter != v3.end(); iter++)
cout << *iter << " ";
cout << endl;
}