LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 887|回复: 2

帮忙看看C++问题,gcc3.2.2能编译过去,但gcc3.4.6不能

[复制链接]
发表于 2006-6-29 17:13:34 | 显示全部楼层 |阅读模式
  1. #include <vector>
  2. template <class TClass>
  3. class test
  4. {
  5.     public:
  6.         test(){};
  7.        ~test(){};
  8.         void hello()
  9.         {
  10.             std::vector<TClass*>::iterator it;
  11.         }
  12. };
  13. main()
  14. {
  15. }
复制代码

std::vector<TClass*>::iterator it;这行出错。
用gcc3.2.2编译时只是警告:
  1. -bash-2.05b$ g++ test.cxx
  2. test.cxx: In member function `void test<TClass>::hello()':
  3. test.cxx:11: warning: `typename std::vector<TClass*, std::allocator<TClass*>
  4.    >::iterator' is implicitly a typename
  5. test.cxx:11: warning: implicit typename is deprecated, please see the
  6.    documentation for details
复制代码

但gcc3.4.6就报错:
  1. test.cxx: In member function `void test<TClass>::hello()':
  2. test.cxx:11: error: expected `;' before "it"
复制代码

这行要怎样改?万分感谢!
发表于 2006-6-29 18:03:24 | 显示全部楼层
将出错的那行改为:

typename std::vector<TClass*>::iterator it;

参见:
http://gcc.gnu.org/gcc-3.4/changes.html
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-6-30 08:55:51 | 显示全部楼层
谢谢!!!!!!!!!!!!!!1
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表