gcc returns error with nested class
- by Nate
Howdy,
I am attempting to use the fully qualified name of my nested class as below, but the compiler is balking!
template <class T> class Apple {
//constructors, members, whatevers, etc...
public:
class Banana {
public:
Banana() {
//etc...
}
//other constructors, members, etc...
};
};
template <class K> class Carrot{
public:
//etc...
void problemFunction()
{
Apple<int>::Banana freshBanana = someVar.returnsABanana(); //line 85
giveMonkey(freshBanana); //line 86
}
};
My issue is, the compiler says:
Carrot.h:85: error: expected ';' before 'freshBanana'
Carrot.h:86: error: 'freshBanana' was not declared in this scope
I had thought that using the fully qualified name permitted me to access this nested class? It's probably going to smack me in the face, but what on earth am I not seeing here??