Muokkaa

Jaa


Add a generic C++ class

You can add a generic C++ class by using Class View. A generic C++ class is a class that you define or that is derived from a class that you define.

To add a generic C++ class to a project:

  1. In Class View, right-click the project to which you want to add the new class, choose Add, and then choose Class.

  2. In the Add Class dialog box, in the templates pane, select C++ Class. Select Add to display the generic C++ class wizard.

  3. In the wizard, provide a class name, and then define settings or accept the defaults.

  4. To close the wizard and view the new generic C++ class in the project, select Finish.

In this section

Generic C++ class wizard

Adds a generic C++ class to a project. The class doesn't inherit from ATL or MFC.

  • Class name

    Sets the name of the new class.

  • .h file

    Sets the name of the header file for the new class. By default, this name is based on the name you provide in Class name. To save the header file to the location of your choice, or to append the class declaration to an existing file, select the ellipsis button (...). If you specify an existing file and select Finish, the wizard prompts you to specify whether the class declaration should be appended to the file contents. To append the declaration, select Yes; to return to the wizard and specify another file name, select No.

  • .cpp file

    Sets the name of the implementation file for the new class. By default, this name is based on the name you provide in Class name. To save the implementation file to the location of your choice, or to append the class definition to an existing file, select the ellipsis button (...). If you specify an existing file and select Finish, the wizard prompts you to specify whether the class definition should be appended to the file contents. To append the definition, select Yes; to return to the wizard and specify another file name, select No.

  • Base class

    Sets the base class for the new class.

  • Access

    Sets access to the base class members for the new class. Access modifiers are keywords that specify the level of access that other classes have to the class member functions. For more information about how to specify access, see Member access control. By default, the class access level is set to public.

    • public
    • protected
    • private
    • Default (No access modifier is generated.)
  • Virtual destructor

    Specifies whether the class destructor is virtual. Use of a virtual destructor helps make sure that the correct destructor is called when instances of derived classes are deleted.

  • Inline

    Generates both the class constructor and the class definition as inline functions in the header file.

  • Managed

    When selected, adds a managed class and header file. When cleared, adds a native class and header file.