#include <iostream>
using namespace std;
template<class T>
void swapNum(T a,T b)
{
T temp;
temp = a;
a = b;
b = temp;
}
int main(void)
{
int x = 10;
int y = 20;
swapNum<int*>(&x,&y);
cout << "x = " << x << endl;
cout << "y = " << y << endl;
return 0;
}
using namespace std;
template<class T>
void swapNum(T a,T b)
{
T temp;
temp = a;
a = b;
b = temp;
}
int main(void)
{
int x = 10;
int y = 20;
swapNum<int*>(&x,&y);
cout << "x = " << x << endl;
cout << "y = " << y << endl;
return 0;
}
老师给的遍历中,for循环的第一个分号前,要有数据才不会出现,提示中的非法字符问题。
要改成这样的形式 for (it = vec.begin(); it!=vec.end(); it++)
要改成这样的形式 for (it = vec.begin(); it!=vec.end(); it++)
6分57秒的代码有问题
vector vec;//缺少类型,应改为vector<string> vec;
vector vec;//缺少类型,应改为vector<string> vec;
2016-05-04