This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: template class scoping rules


Hi,

	Since 3.4, (template-)dependent lookup has been changed to conform
to the standard.  In particular, from http://gcc.gnu.org/gcc-3.4/changes.html:

"In a template definition, unqualified names will no longer find members
of a dependent base."

This allows lookups to be bound at template instantiation time.
(Consider the case where Two<foo> is specialized after Three<T> is
defined, but before Three<foo> is instantiated.)

Two<T> is a dependent base of Three<T>.  Another way of qualifying the
name to lookup is to use "this->m_Public".

HTH

Fang


> test.cpp: In constructor 'Three<T>::Three()':
> test.cpp:20: error: 'm_Public' was not declared in this scope
>
> class One
> {
> public:
> 	One();
> 	~One();
>
> public:
> 	int	m_Public;
> };
>
> template <class T> class Two : public One
> {
> public:
> 	Two() {m_Public = 0;}
> };
>
> template <class T> class Three : public Two<T>
> {
> public:
> 	Three() {m_Public = 0;}
> };



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]