473,569 Members | 2,761 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

typename liability for inherited typedefs

Please consider the following Parent and Child template classes:

template <class T>
class Parent {
public:
typedef T type;
typedef T& ref;
/* pack of typedefs */
};

template<class T>
class Child: public Parent<T>
type data;
public:
ref get() {return data;}
};

(gcc) warning: `Child<T>::type ' is implicitly a typename
implicit typename is deprecated
(same for ref)

which emphasizes the use and importance of `typename' keyword and is
great, unlike MS compiler.... And thus I guess, above code is not
acceptable according to the standards...

But, where does the typename supposed to appear for derived typedefs
(without listing them all over again in Child)?

Jul 23 '05 #1
2 1829
Levent wrote:
Please consider the following Parent and Child template classes:

template <class T>
class Parent {
public:
typedef T type;
typedef T& ref;
/* pack of typedefs */
};

template<class T>
class Child: public Parent<T>
insert:

{
typedef typename Parent<T>::type type;
typedef typename Parent<T>::ref ref;
type data;
public:
ref get() {return data;}
};


[snip]
Best

Kai-Uwe Bux

Jul 23 '05 #2
Levent wrote:
Please consider the following Parent and Child template classes:

template <class T>
class Parent {
public:
typedef T type;
typedef T& ref;
/* pack of typedefs */
};

template<class T>
class Child: public Parent<T>
type data;
public:
ref get() {return data;}
};

(gcc) warning: `Child<T>::type ' is implicitly a typename
implicit typename is deprecated
(same for ref)

which emphasizes the use and importance of `typename' keyword and is
great, unlike MS compiler.... And thus I guess, above code is not
acceptable according to the standards...

But, where does the typename supposed to appear for derived typedefs
(without listing them all over again in Child)?


template <class T>
class Parent {
public:
typedef T type;
typedef T& ref;
/* pack of typedefs */
};

template<class T>
class Child: public Parent<T> {
typename Parent<T>::type data;
public:
typename Parent<T>::ref get() {return data;}
};

Regards,
Larry
--
Anti-spam address, change each 'X' to '.' to reply directly.
Jul 23 '05 #3

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

Similar topics

15
1272
by: Steven T. Hatton | last post by:
I wrote this as part of a request for comments on a mailing list. I realized it summarizes much of what I've been saying about the use of #includes in C++. I'm not asking for the same kind of feedback on this newsgroup as I requested on the mailing list. What I want to ask here is whether what I am describing as a possible alternative is...
1
1156
by: Exits Funnel | last post by:
Hello, I've inherited a bunch of C++ code which was developed on Windows and I'm in the process of trying to port it to Linux/g++. The following is similar to one very small piece of the code: //Begin test1.cpp template<class B> class CHB { };
1
1753
by: lutorm | last post by:
Hi all, I'm working on migrating my code from KCC to gcc, and I'm having some issues with "implicit typename" warnings from gcc. Essentially, what happens is described by this example: template <typename cell_data_type> class cell {}; template <typename a> class c1 { public: typedef cell<a> T_cell;
3
2945
by: Generic Usenet Account | last post by:
This is a two-part question. (1) I have implemented a "Datastructure Registry" template class. I am getting no compiler warnings with older compilers, but newer compilers are generating the following error messages: warning: implicit typename is deprecated, please see the documentation for details Can someone kindly suggest how to get...
6
1727
by: PengYu.UT | last post by:
Hi, I'm wondering why typename can not be inherented from base class. An example is shown below. If I have to typedef value_type anyway, I think it would be easier to define the 5 types in iterator like "typedef T value_type" without inherent from std::iterotor. Thanks, Peng
6
2243
by: blah | last post by:
Hi, Is it possible to force the typename of a template to inherit from a particular class? For example, something like this (conceptual; this doesn't compile): class Parent { public: virtual void vfn() = 0;
30
6062
by: junky_fellow | last post by:
I was looking at the source code of linux or open BSD. What I found that lots of typedefs were used. For example, consider the offset in a file. It was declared as off_t offset; and off_t is typedefed as typedef long off_t; I wanted to know what advantage do we get by typedefs ? Why we did not declare
7
5975
by: Noah Roberts | last post by:
I have something like the following: template<ENUM X, int I = 0> class Generic { .... }; typedef Generic<Val1> v1_type; typedef Generic<Val2> v2_type;
1
1367
by: pauldepstein | last post by:
While reading some source code, I saw a variable called "end" of type "time". So I investigated what the type "time" meant and saw that time was a typedef for "Real". So what does "Real" mean? "Real" is a typedef for QL_REAL. So what does "QL_REAL" mean? QL_REAL is type double via the line of code #define QL_REAL double. I understand...
0
7612
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8120
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7968
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6283
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5512
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1212
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.