错误:“依赖名称不是类型”。当在类中使用typedef类型作为返回值时,使用模板 [英] ERROR: "dependent name is not a type". When use typedef type in class as return value, with template
本文介绍了错误:“依赖名称不是类型”。当在类中使用typedef类型作为返回值时,使用模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
template <class Item>
class bag
{
public:
//TYPEDEF
typedef size_t size_type;
typedef Item value_type;
...
}
b
$ b
and when I use
template<class Item>
bag<Item>::size_type bag<Item>::count(const Item& target) const
$ b b
VC ++报告错误为
Source.cpp(207):warning C4346:'bag :: size_type':依赖的名称不是类型
VC++ report error as Source.cpp(207): warning C4346: 'bag::size_type' : dependent name is not a type
有人能告诉我为什么吗?谢谢!
Could anybody show me why? Thanks!
推荐答案
应该是
template<class Item>
typename bag<Item>::size_type bag<Item>::count(const Item& target) const
这篇关于错误:“依赖名称不是类型”。当在类中使用typedef类型作为返回值时,使用模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文