c++ - Template with struct -


I am designing a binary search tree which allows the user to enter the value of any data type , Not just int .
To achieve this, I am trying to use a template with a structure. I have defined my struct as

  template & lt; Class T & gt; Structure node {struct node * left; T information; Structure node * correct; } * Root;  

Now I'm trying to use it in a class called BST (Binary Search Tree)

  template  

But the compiler is throwing the error, 'node & amp; T> * Route '.
How do I use a template with the structure variables?

You can not declare a root after a template class announcement because Template logic can not be estimated, you can do the following:

  template & lt; Class T & gt; Structure node {struct node * left; T information; Structure node * correct; }; Node and lieutenant; Int & gt; * Route;  

And when you use the node , the template parameter type should be assigned, such as:

  template> ; Class T & gt; Square bst {public: insert zero (node ​​& lt; t & gt; *, node & lt; T & gt; *); Zero inner (node ​​and lieutenant; t & gt; *); };  

Comments