473,408 Members | 1,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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

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

Aug 22 '05 #1
5 3557
Jacky Yuk wrote:
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
Aug 22 '05 #2

"Jacky Yuk" <ja*******@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
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
Aug 22 '05 #3
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

Aug 22 '05 #4
"Jacky Yuk" <ja*******@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
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).
Sep 2 '05 #5
Jim Langston wrote:
[..]
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
Sep 2 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gianni Mariani | last post by:
I remember seeing a neat template specialization trick posted here a few months ago that allowed the detection of a type containing a member. After a day searching through google archives I come up...
10
by: Lionel B | last post by:
Greetings, I cannot figure out why the following code does not compile: --- BEGIN CODE --- typedef double ftype(double); struct A {
2
by: Rudy Ray Moore | last post by:
Whenever I get any error with Vc++7.1/.net/2003, it is followed by huge ammounts of "template assistance" error messaging referencing template code (MTL) that has nothing to do with the error. ...
2
by: Brent | last post by:
Like many sites, mine has a standard "look" -- a template, if you will -- that visitors see on each page. I've tried to keep the code and HTML separate to the extent possible, and for most standard...
9
by: Kobe | last post by:
Is there any difference in: template <class T> vs. template <typename T> ?
0
by: Robbie Hatley | last post by:
I'd always thougth that a C++ compiler/linker should be able to instantiate a template in mulitple places (say, in two different translation units), even using the same template parameters so that...
1
by: Robbie Hatley | last post by:
I asked about this yesterday, but no one bit. So I'll ask again. I can be a persistant cuss. :-) I ran into a problem a few days ago when I added a couple of template functions to one of my...
2
by: Robbie Hatley | last post by:
"Victor Bazarov" <v.Abazarov@comAcast.net> wrote: > Robbie Hatley wrote: > > > > I ran into a problem a few days ago when I added a couple of > > template functions to one of my personal...
2
by: Hukkky | last post by:
File : NodeList.h //---------------------------------------------------------------------- #ifndef NODELIST_H #define NODELIST_H #include <string> using std::string; template <typename T>...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.