nested class in a template

J

John Goche

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
 
B

Bo Persson

John said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,222
Latest member
patricajohnson51

Latest Threads

Top