Microsoft KB Archive/139458

= FIX: Ambiguous C2966 Error with Nested Template Classes =

Article ID: 139458

Article Last Modified on 7/30/2001

-

APPLIES TO


 * Microsoft Visual C++ 4.0 Standard Edition

-



This article was previously published under Q139458



SYMPTOMS
An ambiguous C2966 error is generated if any members of a nested template class are defined externally. The sample code shown in the "More Information" section of this article reproduces this problem and gives the following error message:

error C2966: '' : adding member function of same name as

existing static data member for template class 'Outer'



RESOLUTION
Define members of a nested template class inline only.

NOTE: external definitions with the inline keyword will still generate the ambiguous C2966 error.



STATUS
Microsoft 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.



Sample Code to Reproduce Problem
// Compile option needed: none

template class Outer { public: class Inner { public: static T sobj; static T smfunc(T arg); };

};

//Initialize nested class static object

template  T Outer::Inner::sobj = T;

// Out-of-line definition of nested class static member function // Moving this definition inside class resolves the error template  T Outer::Inner::smfunc(T arg) {      return arg + sobj; }

Additional query words: kbVC400bug 10.00 10.10 10.20

Keywords: kbbug kbfix kblangcpp kbvc500fix KB139458

-

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

© Microsoft Corporation. All rights reserved.