// swap.cpp -- 2011-10-03-16.43
#include "stdafx.h"
#include <iostream>
#include <algorithm>
#include <vector>
using std ::vector ;
using std ::swap ;
int _tmain(int argc, _TCHAR* argv[])
{
int a = 1 ;
int b = 2 ;
std ::cout << a << " " << b << std ::endl ;
// swap (elem1, elem2) ;
// 操作前:elem1和elem2是前向迭代器.
// 操作后:elem1和elem2的值被交换.
// 返回值:无.
// 备注: 形参是引用,实参必须是可写的非const左值.
swap(a, b) ;
std ::cout << a << " " << b << std ::endl ;
std ::cin.get() ;
return 0 ;
}
swap
最新推荐文章于 2024-09-15 17:42:49 发布