BUG: Erroneous C2352 Generated When Using typedef'd Base Class

Last reviewed: July 22, 1997
Article ID: Q115528
7.00 | 1.00 1.50 MS-DOS | WINDOWS kbtool kbbuglist

The information in this article applies to:

  • The Microsoft C/C++ Compiler (CL.EXE), included with:

        - Microsoft C/C++ for MS-DOS, version 7.0
        - Microsoft Visual C++ for Windows, versions 1.0 and 1.5
    

SYMPTOMS

When compiling code using a typedef'd base class, as shown in the sample code below, the compiler incorrectly generates the following error:

   error C2352: 'Base::Print' : illegal call of nonstatic member function

When compiling the same code under C/C++, version 7.0, the following error message is generated instead of the C2352 message:

   error C2653: 'Superclass' : is not a class name

STATUS

Microsoft has confirmed this to be a bug with the C/C++ compiler, versions 7.0, 8.0, and 8.0c. We are researching the problem and will post new information here in the Microsoft Knowledge Base as soon as it becomes available.

This is not a problem in the 32-bit compilers.

Sample Code

/* Compile options needed: /c
*/
      #include <iostream.h>

      class Base
      {
         int i;

      public:

         Base() : i(123) {}
         virtual void Print() { cout << i << '\n'; }
      };

      class Derivd : public Base
      {
         double d;
         typedef Base Superclass;

      public:

         Derivd() : d(3.14159) {}
         virtual void Print1() { Base::Print(); cout << d << '\n'; }
         virtual void Print2() { Superclass::Print(); cout << d << '\n'; }
      };

      main()
      {
         Derivd test;
         test.Print();

         return 0;
      }


Additional reference words: 1.00 1.50 7.00 8.00 8.00c
KBCategory: kbtool kbbuglist
KBSubcategory: CPPIss
Keywords : kb16bitonly


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: July 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.