Need help with fixing this piece of code

Hi (sorry for the unoriginal title, couldn't think of a better one), I'm trying to compile a rather old project which probably was originally made with VC++ 6.0, in a somewhat newer environment.

However as can be expected, there are some things in the code the compiler doesn't like, so far I have been able to fix them but for this piece of code I don't really know how it is correctly solved.

When I try to compile the project the compiler gives me these errors:
1
2
3
4
5
6
7
error C2143: syntax error: missing ';' before '*' - LINE 3
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int - LINE 5
error C2143: syntax error: missing ';' before '*' - LINE 8
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int - LINE 10
error C2143: syntax error: missing ';' before '*' - LINE 15
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int - LINE 15
fatal error C1903: unable to recover from previous error(s); stopping compilation - LINE 15

And here's the code itself (edit: removed most of the code to make things more clear to see).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
template<class N> class Node
{
	N::TData operator*()
	{
		// ...
    }

	N::TData operator*() const
	{
		// ...
    }
 
};

template<class T> Circular<T>::TNode* Circular<T>::pAllocator;

Note that I didn't write any of the above code (and I don't know the original author) so I can't really say why some code sections were written the way they are.

I think I know why the compiler gives me the errors, however as I said I don't know what the correct solution to fix these errors looks like so I'm hoping someone here can give me a hint (or even the solution itself).
Last edited on
gcc wrote:
error: need ‘typename’ before ‘N::TData’ because ‘N’ is a dependent scope
typename N::TData operator*() (similar for the others)
http://www.parashift.com/c++-faq/nondependent-name-lookup-types.html
Thanks that solved it.

Too bad I didn't look at the warnings though (because the output is pretty much spammed with them), then I would have seen warning C4346: 'N::TData' : dependent name is not a type.
Topic archived. No new replies allowed.