Microsoft KB Archive/130551

= FIX: C2974 When Explicitly Call Class Template('s) Destructor =

Article ID: 130551

Article Last Modified on 7/5/2005

-

APPLIES TO


 * Microsoft Visual C++ 2.0 Professional Edition
 * Microsoft Visual C++ 2.1

-



This article was previously published under Q130551



SYMPTOMS
When you explicitly call a class template destructor, and the class object is instantiated with a user defined class in a C++ program, the compiler generates the following compiler errors:

Error C2974 : 'B' : invalid template actual argument '#1', type expected

Error C2039 : 'B ' : is not a member of 'B'

For example, this can happen when you use MFC's collection classes and need to overload the DestroyElement helper function, in which the class destructor can be explicitly called.



RESOLUTION
The following code can be used to work around the problem.

Problem: B a;  a.B::~B; Workaround: B a;  a.B< class A >::~B;



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.



Sample Code to Demonstrate Problem
/* Compile options needed: none.

class A { public: A {} ~A {} };

template < class T > class B { public: B {} ~B {} };

void main {  B a;   // Workaround: change the following line into a comment // and change the line after that into an executed line of code. a.B::~B; // a.B::~B; }

Additional query words: 9.00 2.00 2.10 9.10

Keywords: kbbug kbfix KB130551

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.