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]

template class scoping rules


Hi

This cut down example does not compile with gcc 3.4.x / 4.0.x or 4.1.0.

test.cpp: In constructor 'Three<T>::Three()':
test.cpp:20: error: 'm_Public' was not declared in this scope

It does compile with VS2005 / VS6

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;}
};

this fixes it.

template <class T> class Three : public Two<T>
{
public:
	Three() {Two<T>::m_Public = 0;}
};

any ideas ?

regards
---
Matthew J Fletcher
Embedded Software
Serck Controls Ltd
---
**********************************************************************
Serck Controls Ltd, Rowley Drive, Coventry, CV3 4FH, UK
Tel: +44 (0) 24 7630 5050   Fax: +44 (0) 24 7630 2437
Web: www.serck-controls.com  Admin: post@serck-controls.co.uk
A subsidiary of Serck Controls Pty. Ltd. Reg. in England No. 4353634
**********************************************************************
This email and files transmitted with it are confidential and 
intended solely for the use of the individual or entity to whom they 
are addressed. If you have received this email in error please notify 
the above. Any views or opinions presented are those of the author 
and do not necessarily represent those of Serck Controls Ltd. 


This message has been checked by MessageLabs
******************************************************************


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