Some problems about using template class in Visual C++ 6.0

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

1. If the declaration and definition of a member function of a template class is separated
then while using the auto_complete,the function's information will not be shown.

2. If a member function of a template class is not called by other normal function
then some of it's syntax error can't be find while compiling, maybe this function even haven't be compiled

How could I solve these problems? thank you.
 
BinaryBoy said:
1. If the declaration and definition of a member function of a
template class is separated,
then while using the auto_complete,the function's information will
not be shown.

Intellisense and auto-complete in VC6 has many problems with advanced
features like templates. There's normally nothing you can do.
2. If a member function of a template class is not called by other
normal function,
then some of it's syntax error can't be find while compiling, maybe
this function even haven't be compiled.

This is a limitation of how VC++ compiles C++ code, and to some extent, a
limitation of C++ itself. Template definitions are only barely parsed by
VC++ when they're encountered and aren't subject to a complete syntax check
until they're instantiated. In general, it's not possible for a C++
compiler to determine if a template is valid until it's instantiated (since
the validity of the template depends on the type(s) used in the
instantiation), but VC++ could catch more errors than it does.

The solution to this is to properly test your software - write a test suite
for your template that exercises every member and feature. You do that for
all your code, right?

-cd
 
Thank you for your explanation an advise
I have found a way to solve problem 1
write the declaration and defination together in the class declaration,like the STL

----- Carl Daniel [VC++ MVP] wrote: ----

BinaryBoy wrote
1. If the declaration and definition of a member function of
template class is separated
then while using the auto_complete,the function's information wil
not be shown

Intellisense and auto-complete in VC6 has many problems with advance
features like templates. There's normally nothing you can do
 
Back
Top