Invalid use of template name 'ND' without argument list

Dec 31, 2013 at 5:37pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef BSTCLASS_H_
#define BSTCLASS_H_
#include <string>
using namespace std;


template <typename T>
struct NODE
{
	T data;
	NODE<T> *left;
	NODE<T> *right;
	string colour;
	int LHeight,RHeight;
};

template <typename T>
struct ND
{
	typedef NODE<T>* type;
};

ND node;


I've provided all the code you need here - the error is on the last line and it's snowballing down the rest of the header file making it impossible to actually get any of the functionality of the tree done.
Can anybody tell me how to fix this? After that piece of code all of my errors have something to do with 'ND' not being right and I get stuff like

1
2
3
4
5
6
7
8
9
10
template <class T> class BSTClass
{
public:
	BSTClass(tree);
	~BSTClass();
	void insert(T,ND,TD);
	void Delete(T,ND);
	ND Traversal(T,ND);
	void Balance(ND);
};


-'ND' is not a type; when I use it as a parameter
or
-invalid use of template name 'ND' without argument list; when I use it as a return type.

On some lines I try access the elements inside of 'ND' variables and I get errors saying that those elements don't exist for the given pointers.

Anybody?
Dec 31, 2013 at 5:52pm
ND<int> node; or ND<char> node; or ND<some_data_type> node;
Last edited on Dec 31, 2013 at 5:53pm
Dec 31, 2013 at 5:54pm
I've already told you
ND is a template, you need to provide the template parameter (e.g. ND<int>)
Dec 31, 2013 at 6:48pm
is there any way I can keep it generic though?
Dec 31, 2013 at 7:31pm
Use a generic parameter
1
2
3
4
template <class T>
class BSTClass{
   void Balance(ND<T>);
};

observe how the nodes use the same type as argument as the BST.

You still need to justify the purpose of the global variable in line 23.
Topic archived. No new replies allowed.