Don't know how to define template of a subclass.

Hi I am having a problem with templates.

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
template <class T>
class cListS
{
public:
	cListS(){}
	~cListS(){}

private:

	template <class T>
	class cNode
	{
	public:
		cNode	*fInit( T const &Obj ); // problem is defining this function

		T	mData;
	};
};

// Implementation
template <class T>
cListS<T>::cNode<T> *
cListS<T>::cNode<T>::fInit( T const &Obj )
{
	mData = Obj;
}


I get the warning "Dependant name is not a type".

I try fixing by adding 'typename' to the front of the return type so its like:

1
2
3
4
5
6
template <class T>
typename cListS<T>::cNode<T> *
cListS<T>::cNode<T>::fInit( T const &Obj )
{
	mData = Obj;
}


And now I get the error "unable to match function definition to an existing declaration.

How am I supposed to define fInit()?
Give the inner template parameter a name other than T, which you're already using for cListS<T>
Alright cool, that seemed to do the trick, thanks!
Topic archived. No new replies allowed.