By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,411 Members | 999 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,411 IT Pros & Developers. It's quick & easy.

typename liability for inherited typedefs

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.