做学校网站的内容,手机网站有什么区别,湖北网站建设服务,找苏州网站建设如果对博主其他文章感兴趣可以通过【CSDN文章】博客文章索引找到。 # include iostream
# include vector
using namespace std;templateclass T // 用class或者typename均可
void my_print(T v, const string msg) // v前面不允许加const, 加… 如果对博主其他文章感兴趣可以通过【CSDN文章】博客文章索引找到。 # include iostream
# include vector
using namespace std;templateclass T // 用class或者typename均可
void my_print(T v, const string msg) // v前面不允许加const, 加上之后迭代器也变成常量不可自增
{cout msg endl;// T前面需要加上class/typename,否则出现语法错误 : expression 后出现意外标记 标识符for (class T::iterator it v.begin(); it ! v.end(); it) { cout *it ;}cout endl;
}int main() {vectorstring t { 1, 2, NULL, 5, 3, NULL, NULL }; // 前序遍历my_print(t, 目标树);system(pause);return 0;
}