DOCUMENT:Q131376 29-JUL-2001 [visualc] TITLE :FIX: C2974 Error When Calling Templated Base Class Functions PRODUCT :Microsoft C Compiler PROD/VER::2.0,2.1 OPER/SYS: KEYWORDS:kbCompiler kbCPPonly kbVCkbbuglist kbfixlist ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft C/C++ Compiler (CL.EXE), used with: - *EDITOR Please do not choose this product*Microsoft Visual C++ 32-bit Edition* use 241, 265, 225, versions 2.0, 2.1 ------------------------------------------------------------------------------- SYMPTOMS ======== Calling a member function of a templated base class through the 'this' pointer produces the following erroneous error: error C2974: '' : invalid template actual argument '#1', type expected. RESOLUTION ========== Call the function without using the 'this' pointer. STATUS ====== Microsoft 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 INFORMATION ================ The 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 expected test.cpp(20) : error C2231: '.B::A::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_ERROR template class A { public: Type a; void Afunc(void){}; }; template class B: public A { public: void Bfunc() { #ifdef SHOW_TEMPLATE_ERROR this->A::Afunc(); #else A::Afunc(); #endif } }; void main() { B b; } Additional query words: 2.00 2.10 ====================================================================== Keywords : kbCompiler kbCPPonly kbVC kbbuglist kbfixlist Technology : kbVCsearch kbAudDeveloper kbCVCComp Version : :2.0,2.1 Issue type : kbbug Solution Type : kbfix ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 2001.