我有以下代码:
template<class T>
class RandomTreeNode {
public:
typedef typename RandomTreeFunction<T>::function_ptr function_ptr;
RandomTreeNode(): left(NULL), right(NULL), threshold(0.0), is_a_leaf(false), data(NULL), function(0){
}
void set_function(function_ptr function){this->function = function;}
function_ptr get_function(){ return this->function;}
void set_threshold(double threshold){this->threshold = threshold;}
double get_threshold(){return threshold;}
void create_left_child(){this->left = RandomTreeNode<T>();}
//returning references so that they can be altered in a recursive tree build algo without excessive copying
RandomTreeNode<T>& get_left_child(){return left;}
void create_right_child(){this->right = RandomTreeNode<T>();}
RandomTreeNode<T>& get_right_child(){return this->right;}
bool is_leaf(){return this->is_a_leaf;}
void mark_as_leaf(){this->is_a_leaf = true;}
const std::vector<T> get_data(){
return data;
}
void set_data(std::vector<T>& data){
this->data = data;
}
private:
RandomTreeNode<T> left;
RandomTreeNode<T> right;
double threshold;
function_ptr function;
std::vector<T> data;
bool is_a_leaf;
};
当我编译时,我得到以下error: 'RandomTreeNode<T>::left' has incomplete type
. 任何想法为什么?