Adding a Class
Visual C++ provides several convenient ways to add error-free class declarations to your project.
ClassView, WizardBar, ClassWizard, and the New Class command (Insert menu) assist you with adding classes to an application. All the tools use the same interface (the New Class dialog), except that ClassWizard is limited to MFC-based classes. With ClassView, WizardBar, and the New Class command, you can create MFC (Microsoft Foundation Classes), ATL (Active Template Library), or generic (user-defined) classes. The type of class you add depends on your project type. For example, the default class for an MFC project is an MFC class. However, you can add ATL support to your MFC projects, just as you can add MFC support to your ATL projects.
You can also use the New Class dialog box to add a new class to existing class header and implementation files.
For ATL–based and MFC automation-enabled classes, you define the COM interfaces for the class when you create it. Defining interfaces is not part of creating a user-derived class.
What do you want to do?
Add form-based class
What do you want to know more about?
The New Class dialog box
The New Class Dialog Box
ClassView, WizardBar and ClassWizard all use the New Class dialog box to assist you in adding classes to your projects.
To open the New Class dialog box
Right-click on the project icon in ClassView, and click New Class on the shortcut menu.
-or-
On the WizardBar Action menu, click New Class.
-or-
On the Visual C++ Insert menu, click New Class.
-or-
On the View menu, click ClassWizard. Click ClassWizard's Add Class button, and on the menu click New.
The New Class dialog box has four variants: one for MFC classes, one for ATL classes, one for Generic classes, and one for Form-based classes. The development environment detects the active project type, and modifies the New Class dialog box accordingly. The following table describes the class types that are available from the New Class dialog box for MFC and ATL projects.
Note When you access the New Class dialog box from ClassWizard, these options are not available. ClassWizard supports adding MFC classes only.
MFC .exe Project |
MFC .exe Project with ATL Support |
ATL COM Project | ATL COM Project with MFC Support | |
New MFC Class | x | x | x | |
New ATL Class | x | x | x | |
New Generic Class | x | x | x | x |
New Form Class | x | x | x |
See Also Adding a Member Function, Adding a Member Variable, Overriding a Virtual Function, Adding a Message Handler, Deleting a Member Function, Navigating the Class Structure