Connecting Tech Pros Worldwide Help | Site Map

nested class in a template

 
LinkBack Thread Tools Search this Thread
  #1  
Old September 4th, 2006, 07:25 PM
John Goche
Guest
 
Posts: n/a
Default nested class in a template

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, 08:05 PM
Bo Persson
Guest
 
Posts: n/a
Default 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


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.