FIX: C2670: Template Function Cannot Convert ParameterLast reviewed: September 19, 1997Article ID: Q148808 |
4.00
WINDOWS NT
kbtool kbcode kbbuglist kbfixlist
The information in this article applies to:
SYMPTOMSThe following error is generated:
error C2670: 'AFunction' : the template function cannot convert parameter 1 from type 'class Derived<int> *'in code containing all of the following:
RESOLUTIONTo work around this problem, either explicitly instantiate 'Derived' or create a dummy object of type 'Derived' before calling the 'AFunction'. See the Sample Code for an example.
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Visual C++, 32-bit Edition, version 4.1.
MORE INFORMATION
Sample Code
/* Compile options needed: None */template <class T> class Base { public: T data; int i;}; template <class T> class Derived : public Base<T> { public: int j;}; template <class T> void AFunction(Base<T>* b){ return;}
void main(){ // Uncomment one of the following two statements to work around the // problem. If the template class definition is in a header file, // you may want to include one of the following two statements at // the end of that file. // template Derived<int>; // Derived<int> dummy; Derived<int> *j; AFunction(j); // Gives C2670 here } |
Additional reference words: 4.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |