Connecting Tech Pros Worldwide Forums | Help | Site Map

nested class in a template

John Goche
Guest
 
Posts: n/a
#1: Sep 4 '06
Hello,

Consider the following example:

template <class T>
class A {
private:
T foo;
public:
T Foo() { return foo; }
class B {
private:
T bar;
public:
void FooBar();
T Bar() { return 2 * bar; }
};
};

template <class T>
A<T>::B::FooBar() { }

upong compiling I get the following error:

'typename' is missing in template argument dependent qualified type

which goes away when I type

typename template <class T>
A<T>::B::FooBar() { }

I do not understand why the compiler is confused about A<T>::B being a
type?
What else could it be?

Thanks,

JG


Bo Persson
Guest
 
Posts: n/a
#2: Sep 4 '06

re: nested class in a template


John Goche wrote:
Quote:
Hello,
>
Consider the following example:
>
template <class T>
class A {
private:
T foo;
public:
T Foo() { return foo; }
class B {
private:
T bar;
public:
void FooBar();
T Bar() { return 2 * bar; }
};
};
>
template <class T>
A<T>::B::FooBar() { }
>
upong compiling I get the following error:
>
'typename' is missing in template argument dependent qualified type
>
which goes away when I type
>
typename template <class T>
A<T>::B::FooBar() { }
>
I do not understand why the compiler is confused about A<T>::B being
a
type?
What else could it be?
A qualifier for a function name? :-)

I think the type that is missing is 'void', the return type of FooBar.


Bo Persson


Closed Thread