C++ std::预期为';类型';,但我给它一个类型
这是我的代码:C++ std::预期为';类型';,但我给它一个类型,c++,templates,stl,C++,Templates,Stl,这是我的代码: typedef std::hash_multimap<Vertice<VerticeType, WeightType>*, Edge<VerticeType, WeightType>*> ght; std::pair<ght::iterator, ght::iterator> getEdgesFromVertice(Vertice<VerticeType, WeightType>*); typedef std::has
typedef std::hash_multimap<Vertice<VerticeType, WeightType>*, Edge<VerticeType, WeightType>*> ght;
std::pair<ght::iterator, ght::iterator> getEdgesFromVertice(Vertice<VerticeType, WeightType>*);
typedef std::hash_multimap ght;
std::对getEdgesFromVertice(Vertice*);
当我试图编译它时,它会给我一个错误,说:
error: type/value mismatch at argument 1 in template parameter list for ‘template<class _T1, class _T2> struct std::pair’
error: expected a type, got ‘__gnu_cxx::hash_multimap::iterator’
错误:“模板结构std::pair”的模板参数列表中参数1的类型/值不匹配
错误:应为类型,获取了“\uu gnu\u cxx::hash\u multimap::iterator”
但是std::hash_multimap::iterator不是一种类型吗?我在网上看到的所有示例都对返回类型std::hash\u multimap::equal\u range(key)
感谢您的帮助。谢谢:)这看起来像是在模板中,
VerticeType
等都是模板参数。在这种情况下,您缺少typename
:
std::pair<typename ght::iterator, typename ght::iterator> ...
std::pair。。。
除非使用
typename侧注:单数是顶点,复数是顶点或顶点。