Adding a Member Variable

HomeOverviewHow Do ITutorial

You can add a member variable to a class using ClassView or ClassWizard.

Note   WizardBar does not have the capability of adding a member variable.

To add a member variable using ClassView

  1. In ClassView, select the class to which you want to add a variable.

  2. With the mouse pointer over the selected class, right-click to display the shortcut menu, and click Add Member Variable.

    The Add Member Variable dialog box appears.

  3. In the Variable Type text box, type the Member Variable data type.

  4. In the Variable Name text box, type the variable name.

  5. Select an access specifier for the variable from the Access group of options.

  6. Click OK.

This procedure adds a variable definition to the header file for the class.

To add a member variable using ClassWizard

  1. On the View menu, click ClassWizard. Click the Member Variables tab. Select the class to which you want to add a variable.

  2. Click Add Variable.

  3. The Add Member Variable dialog box appears.

    In the Member variable name text box, type the name of the variable.

    In the Category drop-down list, select the appropriate type of variable (for example, Control).

    In the Variable type drop-down list, select the appropriate class that defines the variable's data type.

  4. Click OK.

This procedure adds a variable definition to the header file for the class.

See Also   Adding a Class, Adding a Member Function, Overriding a Virtual Function, Adding a Message Handler, Deleting a Member Function, Navigating the Class Structure