Microsoft KB Archive/116486

= FIX: Compiler May Generate Invalid Errors for Local Classes =

Article ID: 116486

Article Last Modified on 7/5/2005

-

APPLIES TO


 * Microsoft Visual C++ 1.0 Professional Edition
 * Microsoft Visual C++ 1.5 Professional Edition
 * Microsoft Visual C++ 2.0 Professional Edition

-



This article was previously published under Q116486



SYMPTOMS
The compiler may incorrectly generate the following error messages when compiling code that declares a local class that derives virtually from another class:

C2517: 'identifier' : right of '::' is undefined

C2270: 'identifier' : modifiers not allowed on nonmember functions

C2561: 'identifier' : function must return a value

Under Visual C++ version 2.0, the following errors are generated:

C2653: 'identifier' : is not a class name

C2561: 'identifier' : function must return a value

You can use the sample code in the "MORE INFORMATION" section, below, to illustrate this problem.



RESOLUTION
To avoid the error messages, either do not derive the local class virtually or do not declare both the parent and the derived class as local classes.



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
/* Compile options needed: none

void main {      class B { public: int bi; };             // Class local to main class D : virtual public B { int di; };     // Class derived from // Local class B      D d;   }

Additional query words: 8.00 8.00c 9.00 1.00 1.50 2.00

Keywords: kbbug kbfix kbcpponly kbcompiler KB116486

-

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

© Microsoft Corporation. All rights reserved.