下面的语句怎么会有错误呢?

xinyao06 2010-09-08 01:52:29
定义下面的语句:
typedef _A::reference reference;
typedef _A::const_reference const_reference;


(A是template <typename _Ty, class _A = std::allocator<_Ty> >)

提示错误:

1>f:\练习\.h(117) : warning C4346: '_A::reference' : dependent name is not a type
1> prefix with 'typename' to indicate a type
1> f:\练习.h(185) : see reference to class template instantiation 'CTaggedValueBuffer<_Ty,_A>' being compiled
1>f:\练习\.h(117) : error C2146: syntax error : missing ';' before identifier 'reference'
1>f:\练习\.h(117) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>f:\练习\.h(118) : warning C4346: '_A::const_reference' : dependent name is not a type
1> prefix with 'typename' to indicate a type
1>f:\练习\.h(118) : error C2146: syntax error : missing ';' before identifier 'const_reference'
1>f:\练习\.h(118) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
...全文
57 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
pengzhixi 2010-09-08
  • 打赏
  • 举报
回复
typedef typename _A::reference reference;

NND,位置老弄错
healer_kx 2010-09-08
  • 打赏
  • 举报
回复
(A是template <typename _Ty, class _A = std::allocator<_Ty> >)

代码不全吧?
pengzhixi 2010-09-08
  • 打赏
  • 举报
回复
typename typedef _A::reference reference;

64,693

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧