question templates in managed c

  • Thread starter Thread starter Ana Farcas via .NET 247
  • Start date Start date
A

Ana Farcas via .NET 247

hello, i have an old library i need to port to .net. the old library is written in visual c++ 6.0 and uses templated classes.
if i compile the library (after having gone through the conversion wizard), i get errors with the definitions of the templated classes. below are some examples.

template<class base, class client>
templated_class_name<base,client>::pointer_to_templated_class_member* templated_class_name<base,client><base,client>::templated_class_member(arguments) {
...
code here
... }

for this function i receive the error
error C2143: syntax error : missing ';' before '*'

i did some reading on the templated classes in managed c maybe the synatx changed, but i can't find the problem. maybe you have run into this problem also, and you could advise.

thanks,
Ana Farcas
 
for your information :
'templates' are called 'generics' and are available in .NET 2.0 (whidbey)

so, have a look at how to use 'generics'. maybe you'll find an answer there
http://www.15seconds.com/issue/031024.htm

h.t.h
Chris

Ana Farcas via .NET 247 said:
hello, i have an old library i need to port to .net. the old library is
written in visual c++ 6.0 and uses templated classes.
if i compile the library (after having gone through the conversion
wizard), i get errors with the definitions of the templated classes. below
are some examples.
template<class base, class client>
templated_class_name<base,client>::pointer_to_templated_class_member*
templated_class_name said:
..
code here
.. }

for this function i receive the error
error C2143: syntax error : missing ';' before '*'

i did some reading on the templated classes in managed c maybe the synatx
changed, but i can't find the problem. maybe you have run into this problem
also, and you could advise.
 
Ana said:
for this function i receive the error
error C2143: syntax error : missing ';' before '*'

It's not clear from the code snippet what is causing this error. If you can
send me a preprocessed file, I can take a look. (Take online out of my email
address).
i did some reading on the templated classes in managed c maybe the synatx
changed, but i can't find the problem. maybe you have run into this
problem also, and you could advise.

If you are referring to templates for ref classes and value classes, this is
not supported in the 7.0 and 7.1 versions of the compiler. We are
introducing that support in VC 2005 (currently in beta).

If you are not doing managed programming, which I suspect is the case, the
syntax for templates has changed only slightly. Newer versions of the
compiler support more template features like partial specialization, and are
more restrictive for ill-formed code.
 
hello, i have an old library i need to port to .net. the old library is written in visual c++ 6.0 and uses templated classes.
if i compile the library (after having gone through the conversion wizard), i get errors with the definitions of the templated classes. below are some examples.

template<class base, class client>
templated_class_name<base,client>::pointer_to_templated_class_member* templated_class_name<base,client><base,client>::templated_class_member(arguments) {

That needs to be:

template<class base, class client>
typename
templated_class_name<base,client>::pointer_to_templated_class_member*
templated_class_name<base,client>::templated_class_member(arguments) {

(typename added). VC6 didn't require typename, VC7.1 does require it.
..
code here
.. }

for this function i receive the error
error C2143: syntax error : missing ';' before '*'

i did some reading on the templated classes in managed c maybe the synatx changed, but i can't find the problem. maybe you have run into this problem also, and you could advise.

I don't think the syntax change has anything to do with managed C++,
but purely to do with the major increase in standard C++ conformance
between VC6 and VC7.1. If you don't know about "typename" as used
above, look it up in your favourite reference under "dependent names"
or similar.

Tom
 
Back
Top