C++ templated return type error
I've boiled my problem down to this:
Code:
template<typename T>
class cls
{
public:
class nest
{
public:
T item;
};
T item;
nest *fnc();
};
template<typename T>
cls<T>::nest *cls<T>::fnc()
{
return new nest;
}
int main()
{
return 0;
}
The error is
Code:
temp.cpp:14: error: expected constructor, destructor, or type conversion before '*' token
temp.cpp:14: error: expected `;' before '*' token
Line 14 is
Code:
cls<T>::nest *cls<T>::fnc()
this compiled on visual c++ .net 2003, miraculously. Can anyone understand what's wrong with this construction? I can't see anything incorrect here. I've upgraded from gcc 3.4.2 to 3.4.3 but both are producing the same error message. I've searched google and looked here http://www.parashift.com/c++-faq-lite/ , but no luck.
It doesn't matter that the return type is a pointer. That can be removed and its the same error only it says 'before "cls" '.
-Grady