473,486 Members | 1,850 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

Sep 4 '06 #1
1 1665
John Goche wrote:
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
Sep 4 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2051
by: Andriy Shnyr | last post by:
Let us consider the following nested templates case: template<typename T> class Outer{ public: template<typename U> class Inner{ public:
1
2066
by: Chris Schadl | last post by:
Okay, I'm having a bit of a brain-fart and I can't remember how I would do this. Say I have the following: template <typename T1, typename T2> class A; // Forward declaration of A template...
1
2030
by: nitrogenycs | last post by:
Hello, Code below. I've run into the following problem. I want to pass DCManagedTexture* as a template parameter into the DCDefaultResourceManager template. The DCManagedTexture class is...
8
16848
by: Robert W. | last post by:
I've almost completed building a Model-View-Controller but have run into a snag. When an event is fired on a form control I want to automatically updated the "connnected" property in the Model. ...
4
2065
by: Mr Dyl | last post by:
I'm trying to declare the following friendship and VS.Net 2003 is complaining: template <class T> class Outter { class Inner {...} ... }
2
3320
by: pagekb | last post by:
Hello, I'm having some difficulty compiling template classes as containers for other template objects. Specifically, I have a hierarchy of template classes that contain each other. Template...
4
3008
by: rach | last post by:
I just started to learn C++. I copied the following code from a data structure textbook to a ".h" file and couldn't compile it. The code contains three template interfaces. One inherits another. The...
3
3868
by: jdurancomas | last post by:
Dear all, I'm trying to declare the operator++ to a nested class. The nested class is not template but the container it is. The code used in teh sample program is included bellow: ...
5
3717
by: huili80 | last post by:
For example, like in the following, the part commented out was intended as partial spectialzation, but it would even compile. Is it even legal to partially specialize a nested template class...
2
2272
card
by: card | last post by:
Hi everyone, I have a question about referencing a nested class contained within a templated class. Of course the best way to show you is by example. Here's my templated classes: #include...
0
7094
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7123
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7305
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4863
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
259
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.