I've searched through the web an didn't find any explanation why the following happens.
For example, there is a template class Enclosing with a nested class Nested.
In Enclosing class, there is a method that should create an instance of the Nested class and use it's fields and methods.
In the following code, there is a model of how I'm trying to do it:
template<typename T, typename S>
class Enclosing{
public:
class Nested;
Nested foo();
};
template<typename T, typename S>
class Enclosing<T,S>::Nested{
public:
T field;
void some_method();
friend class Enclosing; // instead of this line I also tried:
// friend class Enclosing<T,S>
// and it didn't work either
};
template<typename T, typename S>
typename Enclosing<T,S>::Nested Enclosing<T,S>::foo (){
Nested nes;
nes.some_method; // the problem appears here
return enc;
}
The problem is:
When I'm writing nes.some_method
, none of the environments I tried (VS2010, eclipse), after I type "nes.", doesn't propose me any options. I seems like "nes" is not an instanse of the class at all.
How to access methods and fields of the nested class from enclosing template class?