Class inside templated class

1
2
template<typename T>
CLinkedListBase<T>::Node* CLinkedListBase<T>::Node::add(T i) // This is the line with the error 

expected constructor, destructor, or type conversion before '*' token


CLinkedListBase is a templated class with another class inside it
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
template<typename T>
class CLinkedListBase {
	public:
		typedef T type;
		class Node {
			public:
				type data;
				Node* next;
				Node(void);
				Node* add(string);
		};
	private:
		Node* root;
		Node* conductor;
		int c;
	public:
		
		CLinkedListBase(T i=T());
		int add(string);
		int remove(string);
		int print(void);
		int fprint(string);
		int size(void);
		string peek(void);
		void next(void);
		void reset(void);
		bool valid(void);
		~CLinkedListBase(void);
};

Assuming I already have all of the member functions implemented elsewhere in the file, how can I fix this code so that it works properly?
I kind of need that function to return a Node pointer...
Last edited on
The compiler may not know that CLinkedListBase<T>::Node is a type so add typename before it:
typename CLinkedListBase<T>::Node* CLinkedListBase<T>::Node::add(T i)
Notice that in your class the prototype has a string parameter, here you have a T parameter
Thanks, using typename fixed it!
Yeah, I noticed that little glitch too, but I fixed it after I posted.
Topic archived. No new replies allowed.