FIX: C2974 Error When Calling Templated Base Class FunctionsLast reviewed: September 18, 1997Article ID: Q131376 |
2.00 2.10
WINDOWS NT
kbtool kbfixlist
The information in this article applies to:
SYMPTOMSCalling a member function of a templated base class through the 'this' pointer produces the following erroneous error:
error C2974: '<base templated class name>' : invalid template actual argument '#1', type expected. RESOLUTIONCall the function without using the 'this' pointer.
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem was fixed in Microsoft Visual C++, 32-bit Edition, version 4.0.
MORE INFORMATIONThe Visual C++ compiler generates the following errors when the following sample program (TEST.CPP), is compiled with the /D"SHOW_TEMPLATE_ERROR" option: test.cpp(20) : error C2974: 'A' : invalid template actual argument '#1', type expectedtest.cpp(20) : error C2231: '.B<int,int>::A<int>::Afunc' : left operand points to 'class', use '->'test.cpp(20) : fatal error C1903: unable to recover from previous error(s); stop ping compilation Sample Code to Demonstrate Problem
/* Compile options needed: none */ // #define SHOW_TEMPLATE_ERRORtemplate <class Type> class A { public: Type a; void Afunc(void){};}; template <class Type1, class Type2> class B: public A<Type1> { public: void Bfunc() {#ifdef SHOW_TEMPLATE_ERROR this->A<Type1>::Afunc();#else A<Type1>::Afunc();#endif }};
void main(){ B<int, int> b;}
|
Additional reference words: 2.00 2.10
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |