C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Embedded class' or VC++7 compiler's problem ?

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
N4M
Guest





PostPosted: Wed Sep 29, 2004 9:40 am    Post subject: Embedded class' or VC++7 compiler's problem ? Reply with quote



Dear,
I have codes as follows:
template<class T>
class A {
public: // embedded class
class E;
public: // types
typedef E TE;
public:// member functions
TE somefunc();
private: // member data
//----------------------------
// embedded class
public:
class E {
//.....//
};
};
//
template<class T>
A<T>::TE A<T>::somefunc() {....}

When I compile these codes with VC++.NET, there are error messages:

c:DATAC++Commonlist.h(389): error C2143: syntax error : missing
';' before 'list_base<TNValue>::insert'
c:DATAC++Commonlist.h(389): error C2501:
'list_base<TNValue>::iterator' : missing storage-class or type
specifiers

// TNValue = T, list_base = A, iterator = TE

The same codes are compilled without problem by VC++ 6.

How come?
Is there something not-so-good with my embedded class use? Do you
recommend embedded classes or have other better solutions?

Thansk for your time.
Nguyen Mai

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Alberto Barbati
Guest





PostPosted: Thu Sep 30, 2004 10:34 am    Post subject: Re: Embedded class' or VC++7 compiler's problem ? Reply with quote



N4M wrote:

Quote:
template<class T
A

seems a typename is missing here. It shoud be:

template<class T>
typename A<T>::TE A<T>::somefunc() {....}
^^^^^^^^

Quote:
When I compile these codes with VC++.NET, there are error messages:

c:DATAC++Commonlist.h(389): error C2143: syntax error : missing
';' before 'list_base<TNValue>::insert'
c:DATAC++Commonlist.h(389): error C2501:
'list_base<TNValue>::iterator' : missing storage-class or type
specifiers

When I compile the above code, in addition to those error messages I
also get this warning:

warning C4346: 'A<T>::TE' : dependent name is not a type
prefix with 'typename' to indicate a type

that clearly hints to the right answer. You did *not* turn off warnings,
didn't you? ;-)

Quote:
The same codes are compilled without problem by VC++ 6.

How come?

VC++ 6 was not conformant about the use of the typename keyword and
incorrectly allowed a relaxed parsing.

Hope it helps,

Alberto

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
James Hopkin
Guest





PostPosted: Fri Oct 01, 2004 5:23 pm    Post subject: Re: Embedded class' or VC++7 compiler's problem ? Reply with quote



[email]dnguyenk (AT) yahoo (DOT) com[/email] (N4M) wrote in message news:<6e8e8a14.0409280855.4a6e8841 (AT) posting (DOT) google.com>...
Quote:

How come?
Is there something not-so-good with my embedded class use? Do you
recommend embedded classes or have other better solutions?


The code you posted is fine.

The error message involves a list of some sort. There is no list
mentioned in the code you posted. Can you post more of the relevant
code?


James

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.