 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
N4M Guest
|
Posted: Wed Sep 29, 2004 9:40 am Post subject: Embedded class' or VC++7 compiler's problem ? |
|
|
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
|
Posted: Thu Sep 30, 2004 10:34 am Post subject: Re: Embedded class' or VC++7 compiler's problem ? |
|
|
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
|
Posted: Fri Oct 01, 2004 5:23 pm Post subject: Re: Embedded class' or VC++7 compiler's problem ? |
|
|
[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 |
|
 |
|
|
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
|
|