In Class View, you can add a member function to any class. When you do this, a declaration is added to the header file, and a stub member-function body is added to the class's implementation file, which you can then modify.
To add a member function to a class:
-
In Class View, expand the project node to display the classes in the project. (To open Class View, on the menu bar, choose View, Class View.)
-
Open the shortcut menu for the class you want to add a member function to, and then choose Add, Add Function.
-
Provide the appropriate details about the member function. For more information, see Add member function wizard.
-
Choose the Finish button to generate the member function code.
This wizard adds a member function declaration to the header file. It also adds a stub member function implementation to the implementation file for the selected class.
Once you've added the member function using the wizard, you can edit the code in the development environment.
-
Return type
Sets the return type for the member function you're adding. You can provide your own return type, or you can select from the list of available types. For information about the types, see Fundamental types.
:::row:::
:::column span="":::
char
double
float
int
:::column-end:::
:::column span="":::
long
short
unsigned char
unsigned int
:::column-end:::
:::column span="":::
unsigned long
void
HRESULT
:::column-end:::
:::row-end:::
-
Function name
Sets the name of the member function you're adding.
-
Parameter type
Sets the type of parameter you're adding for the member function, if the member function has parameters. You can provide your own parameter type, or you can select from the list of available types.
:::row:::
:::column span="":::
char
double
float
:::column-end:::
:::column span="":::
int
long
short
:::column-end:::
:::column span="":::
unsigned char
unsigned int
unsigned long
:::column-end:::
:::row-end:::
-
Parameter name
Sets the name of a parameter you're adding for the member function, if the member function has parameters.
-
Parameter list
Displays a list of parameters you've added to the member function. To add a parameter to the list, provide a type and name in the Parameter type and Parameter name boxes and select Add. To remove a parameter from the list, select the parameter and select Remove.
-
Access
Sets the access to the member function. Access modifiers are keywords that specify the access other classes have to the member function. For more information about specifying access, see Member-access control. The member function access level is set to
publicby default.Check whether the new member function is static or virtual, and whether it's inline or pure. If you set the member function to be pure, the Virtual check box is selected, and the Inline check box becomes unavailable. The default is a nonstatic, nonvirtual member function.
-
.cpp file
Sets the file location where the stub member function implementation is written. By default, it's written to the .cpp file for the class to which the member function is added. Select the ellipsis button to change the file name. The member function implementation is added to the contents of the selected file.
-
Comment
Provides a comment in the header file for the member function.
-
Function signature
Displays the member function verbatim from the code when you select Finish. You can't edit the text in this box. To change the member function, change the appropriate boxes in the wizard.
