Adding a Member Variable
Home | Overview | How Do I | Tutorial
You can add a member variable to a class using ClassView or ClassWizard.
-
If you want to add a generic C++ member variable, you must use ClassView.
-
If you want to add a member variable for data exchange and data validation, you must use ClassWizard. ClassWizard is specifically designed to take the relevant information and use it to insert elements in your source files at the appropriate locations. ClassView adds a plain variable declaration to the header file.
Note WizardBar does not have the capability of adding a member variable.
To add a member variable using ClassView
-
In ClassView, select the class to which you want to add a variable.
-
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.
-
In the Variable Type text box, type the Member Variable data type.
-
In the Variable Name text box, type the variable name.
-
Select an access specifier for the variable from the Access group of options.
-
Click OK.
This procedure adds a variable definition to the header file for the class.
To add a member variable using ClassWizard
-
On the View menu, click ClassWizard. Click the Member Variables tab. Select the class to which you want to add a variable.
-
Click Add Variable.
-
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.
-
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