Problem on using "template" in VC/C++ 6.0

J

Jacky Yuk

Hi all,

I am new to c++ but using c for long time. Recently, I created a MFC
GUI project by VC/C++ 6.0. Everything was fine until I wanted to use
"template":

template <typename T>
class AutoComPtr { ...

The following errors were shown:

..\external\include\autocom.hpp(18) : error C2059: syntax error : '>'
..\external\include\autocom.hpp(62) : error C2992: 'AutoComPtr' :
invalid or missing template parameter list
.\external\include\autocom.hpp(62) : see declaration of
'AutoComPtr'
..\external\include\autocom.hpp(67) : error C2059: syntax error : '>'


Furthermore, I even can't include "<iostream>" (but "iostream.h"). It
gave the following errors in the file "iosfwd":

C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\iosfwd(215) :
error C2079: '$S202' uses undefined class '$S202'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\iosfwd(215) :
error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\iosfwd(260) :
error C2975: 'allocator' : invalid template argument for '$S202',
constant expression expected
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\iosfwd(216) : see
declaration of 'allocator'

Could anyone tell me what're the error about. Thanks so much.

Best Regards,
Jacky
 
V

Victor Bazarov

Jacky said:
I am new to c++ but using c for long time. Recently, I created a MFC
GUI project by VC/C++ 6.0. Everything was fine until I wanted to use
"template":

template <typename T>
class AutoComPtr { ...

The following errors were shown:

.\external\include\autocom.hpp(18) : error C2059: syntax error : '>'
.\external\include\autocom.hpp(62) : error C2992: 'AutoComPtr' :
invalid or missing template parameter list
.\external\include\autocom.hpp(62) : see declaration of
'AutoComPtr'
.\external\include\autocom.hpp(67) : error C2059: syntax error : '>'

And where are the lines 18, 62, and 67? Have you read the FAQ? You
should, you know. Before posting again.

V
 
B

benben

Jacky Yuk said:
Hi all,

I am new to c++ but using c for long time. Recently, I created a MFC
GUI project by VC/C++ 6.0. Everything was fine until I wanted to use
"template":

template <typename T>
class AutoComPtr { ...

The following errors were shown:

.\external\include\autocom.hpp(18) : error C2059: syntax error : '>'
.\external\include\autocom.hpp(62) : error C2992: 'AutoComPtr' :
invalid or missing template parameter list
.\external\include\autocom.hpp(62) : see declaration of
'AutoComPtr'
.\external\include\autocom.hpp(67) : error C2059: syntax error : '>'


Furthermore, I even can't include "<iostream>" (but "iostream.h"). It
gave the following errors in the file "iosfwd":

C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\iosfwd(215) :
error C2079: '$S202' uses undefined class '$S202'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\iosfwd(215) :
error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\iosfwd(260) :
error C2975: 'allocator' : invalid template argument for '$S202',
constant expression expected
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\iosfwd(216) : see
declaration of 'allocator'

Could anyone tell me what're the error about. Thanks so much.

Best Regards,
Jacky

Although you should upgrade to more standard-compliant compilers (e.g.
VC7.1), the error is most likely caused by your code. It could be a typo or
something more serious. Perhaps posting the lines where errors occur might
give us more clue to help you help yourself.

Ben
 
J

Jacky Yuk

Hi,

Thx so much, it looks to be the problem of other codes. It can be
compiled if I put the statements before some codes. I am now
invesgating my program. Furthermore, sorry for the unclear questions, I
will read the faq before next post.

Best Regards,
Jacky
 
J

Jim Langston

Jacky Yuk said:
Hi,

Thx so much, it looks to be the problem of other codes. It can be
compiled if I put the statements before some codes. I am now
invesgating my program. Furthermore, sorry for the unclear questions, I
will read the faq before next post.

Best Regards,
Jacky

I concider 6.0 broken. I used to use it when it was the latest. It doesn't
seem to support <iostream> but only the older <iostream.h> type headers.
Other things don't work in it as well. I'm using Microsoft Visual C++ .net
2003 now and all those problems go away (although I only use c++ not the
..net managed stuff).
 
V

Victor Bazarov

Jim said:
[..]
I concider 6.0 broken. I used to use it when it was the latest. It doesn't
seem to support <iostream> but only the older <iostream.h> type headers.

This is simply not true.
Other things don't work in it as well. I'm using Microsoft Visual C++ .net
2003 now and all those problems go away (although I only use c++ not the
.net managed stuff).

That's true, OTOH.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top