Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8735853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:09:59+00:00 2026-06-13T10:09:59+00:00

I have the following code: template<class T> class RandomTreeNode { public: typedef typename RandomTreeFunction<T>::function_ptr

  • 0

I have the following code:

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;

};

When I compile, I get the following error: 'RandomTreeNode<T>::left' has incomplete type. Any ideas why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:10:00+00:00Added an answer on June 13, 2026 at 10:10 am

    Because it’s the type you’re currently defining. It doesn’t make sense for a type to have a member of the same type (for starters, it would have an infinite size). I think what you want is to have pointers to RandomTreeNode<T>‘s, not direct instances.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following small code: template <typename T> class V { public: T
I have the following code: template<class T> class RandomTreeNode { private: RandomTreeNode<T> *left; RandomTreeNode<T>
I have the following code: class TimeOutException {}; template <typename T> class MultiThreadedBuffer {
I have the following code: template <typename Provider> inline void use() { typedef Provider::Data<int>
I have the following code: template<typename T, typename Allocator = std::allocator<T> > class Carray
gcc 4.5.1, SuSE Linux i686 Suppose we have following code: template<typename realT> class B
So I have the following code: template<class T> class A { public: class B
So I have the following code: #include <iostream> template <typename T> class funcky {
let's say I have the following code in A.cpp file: template <typename T> class
I have following template code: class ClassName{}; template <class T> class TemplatePtr { public:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.