Connecting Tech Pros Worldwide Help | Site Map

nested class in a template

  #1  
Old September 4th, 2006, 08:25 PM
John Goche
Guest
 
Posts: n/a
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

  #2  
Old September 4th, 2006, 09:05 PM
Bo Persson
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nested class in a template =?ISO-8859-1?Q?Andr=E9_Luiz_Carvalho?= answers 2 August 4th, 2008 03:45 PM
can't use typedef of nested class in template class Frank Bergemann answers 5 December 13th, 2007 02:55 AM
Howto declare a friend function to a nested class jdurancomas@gmail.com answers 3 September 30th, 2007 04:35 PM
linking problem with nested class in template class Dominik Fritz answers 2 July 23rd, 2005 04:38 AM