2013-02-07 62 views
0

几周前我开始使用模板,但使用它时遇到问题。 我得到这个错误:模板类中定义的类型“不命名类型”

自由式/ _gl /../_ convection_selective/Definitions.h:153:9:错误:Node_handle'在“Point_set {又名结构Kd_tree_patch>> *,My_point_property_map,CGAL :: Search_traits>>,常量双*,Construct_coord_iterator>>>}” 没有指定类型

在编译的代码:

“Definitions.h”:

#include "Kd_tree_patch.h" 
[...] 
template <class SearchTraits, class Splitter_= CGAL::Sliding_midpoint<SearchTraits>, class UseExtendedNode = CGAL::Tag_true > class Kd_tree_patch; //forward declaration 

typedef Kd_tree_patch<Search_traits> Point_set;  
typedef Point_set::Node_handle Node_handle; 

“Kd_tree_patch.h”

template <class SearchTraits, class Splitter_=Sliding_midpoint<SearchTraits>, class UseExtendedNode = Tag_true > 
class Kd_tree_patch { 
[...] 
typedef Kd_tree_node<SearchTraits, Splitter, UseExtendedNode > Node; 
typedef typename Compact_container<Node>::iterator Node_handle; 
}; 

为什么Node_handle不被视为一种类型了吗?

感谢您的帮助。

+0

你缺少一个'typename'存在(这是一个依赖型)... – Nim

+0

你开始几周前使用模板?啊呀。 – Salgar

+0

@NIm你的意思是:typedef typename Point_set :: Node_handle Node_handle;如果是这样,我尝试了,但我得到了同样的错误。 – Kamouth

回答

2

不能向前声明嵌套类型,这意味着能够使用嵌套式Node_handle,模板Kd_tree_patch必须 typedef的之前定义。一旦你解决这个问题,你还需要指示编译器,它是通过使用typename类型:

typedef typename Point_set::Node_handle Node_handle; 
//  ^^^^^^^^ 
+0

+1我错过了前向宣言位... – Nim

+0

感谢您的帮助! – Kamouth