c++ - Class property includes instance of a template class (error C3857) -
i implementing binary tree class identical this one. however, in task, node struct must templated structure. therefore changed struct node to:
template <typename t> class node { public: t data; node<t> *left, *right; } so far good, until added node instance btree member variable:
class btree { // ...... private: template <typename t> node<t> *root = null; // error } error message says
c3857: multiple template parameter lists not allowed.
i tried move root = null btree's default constructor, not work either.
you cannot have templated variable declaration. there no way specify type use variable. can either make btree template , use type node
template<typename t> class btree { // ...... private: node<t> *root = null; // error } or specify type of node want in btree
class btree { // ...... private: node<some_type> *root = null; // error }
Comments
Post a Comment