STL - Container/Container - Array
Array - swap()
Programmer.
2016. 1. 28. 18:29
소스)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include<array> #include<iostream> #define Max_Size 10 void print(std::array<int, Max_Size> Target_Array) { for (std::array<int, Max_Size>::iterator IterPos = Target_Array.begin(); IterPos != Target_Array.end(); ++IterPos) std::cout << *IterPos << " "; std::cout << std::endl; } void main() { std::array<int, Max_Size > Array = { 1,3,5,7,9,11,13,15,17,19}; std::array<int, Max_Size> Array_copy = { 0, }; print(Array); print(Array_copy); Array.swap(Array_copy); print(Array); print(Array_copy); } | cs |
내용)
swap 함수는 두개의 array의 내용을 완전히 바꿔 줍니다.
결과)