FIX: C2084 When Template Class Constructor Has No BodyLast reviewed: September 19, 1997Article ID: Q150573 |
The information in this article applies to:
SYMPTOMSThe following error occurs when a template class is explicitly instantiated and it has more than one constructor, at least one of which does not have a body defined and at least one of which is defined outside of the class:
error C2084: function '<function name>' already has a body WORKAROUND
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ version 5.0.
MORE INFORMATION
Sample Code
/* Compile options needed: /c
*/
template <class T>
class A {
public:
A(); // give this ctor a body for workaround 1
A(const T&);
};
template <class T> A<T>::A(const T&) {}; // move this ctor body
// inside the class
// definition for
// workaround 2
template A<int>; // this is an explicit instantiation -
// comment this line out and uncomment the
// next line for workaround 3
// A<int> x = 3; // this is an implicit instantiation
Keywords : CPPIss vcbuglist400 vcfixlist500 kbprg Version : 4.1 4.2 Platform : NT WINDOWS Issue type : kbbug Solution Type : kbfix |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |