?
Solved

compiling templates in VC++ 5.0

Posted on 1997-04-22
4
Medium Priority
?
406 Views
Last Modified: 2008-03-06
I get a syntax error compiling the following template in
VC++ 5.0. The code is the winsock sdk code available from
microsoft. The code compiled under the old developer studio.
I could not find any option to get it compiled in the new
one.
I add line numbers to the code:

36:template<class T> class NILNode_c {
37:    friend class NIDeque_c<T>;
38:    friend class NIDequeIter_c<T>;
39:
40:    public:
41:      NILNode_c();
42:
43:    private:
44:        T           Data;
45:        NILNode_c   *Next,
46:                    *Back;
47:};

--------------------Configuration: dtwin - Win32 Debug--------------------
Compiling...
DT_DLL.CPP
C:\winsock\SAMPLES\DT_DLL\dtwin\nideque.h(37) : error C2059: syntax error : '<'
C:\winsock\SAMPLES\DT_DLL\dtwin\nideque.h(37) : error C2238: unexpected token(s) preceding ';'
C:\winsock\SAMPLES\DT_DLL\dtwin\nideque.h(38) : error C2059: syntax error : '<'
C:\winsock\SAMPLES\DT_DLL\dtwin\nideque.h(38) : error C2238: unexpected token(s) preceding ';'
C:\winsock\SAMPLES\DT_DLL\dtwin\nideque.h(69) : error C2989: 'NIDeque_c' : template class has already been defined as a non-template class
C:\winsock\SAMPLES\DT_DLL\dtwin\nideque.h(114) : error C2059: syntax error : '<'
C:\winsock\SAMPLES\DT_DLL\dtwin\nideque.h(141) : error C2588: '::~NIDeque_c' : illegal global destructor
C:\winsock\SAMPLES\DT_DLL\dtwin\nideque.h(141) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.

dtwin.dll - 8 error(s), 0 warning(s)
0
Comment
Question by:mkhare
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Expert Comment

by:snemanov
ID: 1162900
Please, mark what line is #37 ?
0
 

Author Comment

by:mkhare
ID: 1162901
Edited text of question
0
 

Accepted Solution

by:
snemanov earned 100 total points
ID: 1162902
Formally, friend class X; is not a class declaration.There was some disorder with it in the previous compiler versions.MSVC++ 5.0 has more strong approach to types declaration,so you should define NIDeque_c and NIDequeIter_c classes as template classes before NILNode_c class.Addtemplate<class T> class NIDeque_c;
template<class T> class NIDequeIter_c;
lines before the line #36 or include an appropriate header file.Feel free to ask additional questions if any.Regards, Sergey
0
 

Author Comment

by:mkhare
ID: 1162903
i have compiled the code successfully using your suggestion
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question