BUG: C2065 When Default Constructor of a Nested Class Called

Last reviewed: May 21, 1997
Article ID: Q168373
The information in this article applies to:
  • Microsoft Visual C++, 32-bit Editions, version 5.0

SYMPTOMS

When the default constructor of a nested class gets called, it causes the C2065 compiler error:

   'identifier' : undeclared identifier

RESOLUTION

Look at the More Information section for a workaround.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

NOTE: Because constructors do not have names, they are never found during name lookup; however an explicit type conversion using the functional notation will cause a constructor to be called to initialize an object. (This information came from the C++ Working Paper.)

The following sample code demonstrates the problem and the workaround.

Sample Code

   /*
   Compile options: None
   */

   class Base
   {
   public:
       class Common
       {
       public:
          Common(){};
       };
       class Derived : public Common
       {
       public:
          Derived() {}
          Derived(int n) {}
       };
       Base( const Common &theCommon) {}
   };


   int main(void)
   {
       Base B1(Base::Derived());  //C2065 here

       // Workaround: Comment the above line
       // Uncomment the following lines
       // Base::Derived D ;
       // Base B1(D) ;
       return 0;
   }
 

	
	


Keywords : CPPIss CPPLngIss kbcode kberrmsg kbtool vcbuglist500 kbbuglist
Version : 5.0
Platform : NT WINDOWS
Issue type : kbbug


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.

Last reviewed: May 21, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.