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

请教这个函数模板为什么不能这样使用

2012-03-09 
请问这个函数模板为什么不能这样使用?代码如下,#includeiostream#includecstdlib#includelistusingn

请问这个函数模板为什么不能这样使用?
代码如下,
#include   <iostream>
#include   <cstdlib>
#include   <list>

using   namespace   std;

template   <typename   T>
void   print(const   list <T>   &_tlist   )
{
          list <T> ::const_iterator   ibeg=_tlist.begin();//在编译的时候,就是这句不能通过
          for(;ibeg!=_tlist.end();ibeg++){
                  cout < <*ibeg < < '   ';
          }
          system( "PAUSE ");
          cout < <   endl;
          return;
}

int   main()
{
        int   a[]={2,3,6,9,13};
        list <int>   _ilist(a,a+5);
        print(_ilist);
}

请问为什么list <T> ::const_iterator不能被识别?

[解决办法]
试下把
list <T> ::const_iterator ibeg=_tlist.begin();
换成
typename list <T> ::const_iterator ibeg=_tlist.begin();

热点排行