首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

新手,vector编译时出现的有关问题

2012-03-09 
新手,vector编译时出现的问题使用VC++6.0创建一个Win32consoleApplication工程,填入如下代码:#includestd

新手,vector编译时出现的问题
使用VC++6.0创建一个Win32     console   Application工程,填入如下代码:
#include   "stdafx.h "
#include   <iostream>
#include   <vector>
using   namespace   std;

void   print(vector::const_iterator   beg;vector::const_iterator   end){
while(beg   !=   end){
cout   < <   *beg;
if(beg   !=   end)   cout   < <   "   ";
}
cout   < <   endl;
}


int   main()
{

return   0;
}

编译时总是报错:
...   :   error   C2955:   'vector '   :   use   of   class   template   requires   template   argument   list

是什么原因?#include   "stdafx.h "新建工程后就有的,这是干什么用的?

[解决办法]
requires template argument list,已经写了啊,你的vector没有模版参数列表,编译器没办法在编译时候知道你那个函数的参数类型。
[解决办法]
#include "stdafx.h "
是设置工程环境的。

vector是一个模板类,你要使用,要选择具体的类型
如:vector <int> vec;
[解决办法]
beg;vector <int> ...
改为逗号

循环里加上
++beg;

[解决办法]
楼主写错了,void print(vector <int> ::const_iterator beg;vector <int> ::const_iterator end)应该是void print(vector <int> ::const_iterator beg,vector <int> ::const_iterator end)。

热点排行