PRB: Unable to Derive Classes from External Dependencies

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

SYMPTOMS

When you try to create a new class derived from a generic class using Insert.New Class wizard in the IDE, you may get the following error message:

   The New Class Wizard could not find the appropriate header file(s) to
   include for the base class(es) CTestClass. If you choose to derive
   from the class(es) anyway, you may need to manually add the
   appropriate header file(s) to C:\Temp\CTestClassDerived.h

CAUSE

The New Class Wizard can not derive classes from the classes that are only in the external dependencies. That is, if the base class' header file, where the base class is declared, is not included in the project, the wizard cannot add the header to the derived class' header file.

RESOLUTION

To resolve the problem, you can do one of the following:

  • Close the message box and derive the class anyway. Add the base class header file manually to the derived class' header file.

-or-
  • Add the base class header file to the project. This can be done through the Project.Add to Project.Files menu in the IDE. After doing this, you should be able to derive the class without any warning messages.

STATUS

This behavior is by design.

MORE INFORMATION

The following procedures can be used to reproduce the problem.

Steps to Reproduce Behavior

  1. UsE the AppWizard to generate a generic MFC application.

  2. Create a header file named CTestClass.h in which you declare a base class. Make sure CTestClass.h is not added to the project.

  3. Create a C++ source file named CTestClass.cpp in which you define all the member functions in the base class. You can add CTestClass.cpp to the project if you choose to.

  4. If you did include CTestClass.cpp to the project in step 3, add it to the project now.

  5. Derive a class from CTestClass. You can do so by choosing Insert.New Class menu in the IDE. In the "Class type:" choose "Generic Class". Name the derived class CTestClassDerived. Enter CTestClass as the class name for the "Derived From" text.

  6. Click OK to save the derivation and exit the New Class dialog box.

  7. You should get the error message box mentioned above before the dialog box is closed.


Additional query words: member methods wizards
Keywords : VWBIss
Version : 5.0
Platform : NT WINDOWS
Issue type : kbprb


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