I have a class nested in a template class and a function in the template
class which returns the nested class type. I get compile error when
compiling with the function definition outside the class definition, but
not inside, and I don't understand why. Can anybody help?
Compiler: gcc 4.1.2
Here is a similiar, but simpler code to illustrate the problem:
#include <iostream>
using namespace std;
template <class T>
class out{
public:
class in{
public:
int a;
in(){};
in(int _a) : a(_a){};
};
out(){};
in func(); //This does not work
// in func(){return in(3);}; //This works
};
template <class T>
out<T>::in out<T>::func(){return in(3);};
int main()
{
out<intout_obj;
out<int>::in in_obj=out_obj.func();
cout << in_obj.a << endl;
}
__________________________________________________ ______
Output:
test.cpp:21: error: expected constructor, destructor, or type conversion
before ‘out’
helge