|
1 | 1 | ---
|
2 |
| -description: "Learn more about: Add a method to an interface in a Visual C++ project" |
| 2 | +description: "Learn more about: Add a method to an interface in a Microsoft Visual Studio C++ project" |
3 | 3 | title: "Add a method"
|
4 |
| -ms.date: "03/21/2022" |
| 4 | +ms.date: "03/28/2022" |
5 | 5 | f1_keywords: ["vc.codewiz.method.overview", "vc.codewiz.method.idlattrib"]
|
6 | 6 | helpviewer_keywords: ["add method wizard [C++]", "methods [C++], adding", "methods [C++], adding using wizards", "IDL attributes, add method wizard"]
|
7 | 7 | ms.custom: devdivchpfy22
|
8 | 8 | ---
|
9 | 9 | # Add a method
|
10 | 10 |
|
11 |
| -You can use the [add method wizard](#add-method-wizard) to add a method to an interface in your project. In your project, add interface and follow the given steps to get the **Add method** wizard. If the project contains a class associated with the interface, the wizard modifies the class, too. |
| 11 | +Use the [add method wizard](#add-method-wizard-dialog-box) to add a method to an interface in your project. If the project contains a class associated with the interface, the wizard also adds the method to the class. |
12 | 12 |
|
13 |
| -**To add a method to your object:** |
| 13 | +**Add a method to your interface:** |
14 | 14 |
|
15 |
| -1. In **Class View**, expand the project node to display the interface to which you want to add the method. |
| 15 | +1. From the Visual Studio main menu, choose **View** > **Class view**. In the **Class View** pane, expand the project node to display the interface you want to add the method to. |
16 | 16 |
|
17 | 17 | > [!NOTE]
|
18 |
| - > You can also add methods to dispinterfaces, which, unless the project is attributed, are located under the library node. |
| 18 | + > You can also add methods to dispinterfaces. Unless the project is attributed, dispinterfaces are located under the library node. |
19 | 19 |
|
20 | 20 | 1. Right-click the name of the interface.
|
21 | 21 |
|
22 |
| -1. On the shortcut menu, choose **Add**, and then choose **Add Method**. |
| 22 | +1. On the shortcut menu, choose **Add** > **Add Method**. |
23 | 23 |
|
24 |
| -1. In the **Add Method** wizard, provide the information to create the method. |
| 24 | +1. In the **Add Method** wizard dialog box, provide the information to create the method as described in the next section. |
25 | 25 |
|
26 | 26 | 1. Select **OK** to add the method.
|
27 | 27 |
|
28 |
| -## Add method wizard |
| 28 | +## Add method wizard dialog box |
29 | 29 |
|
30 |
| -Use this wizard to add a method to an interface. |
| 30 | +Add a method to an interface by using the add method wizard dialog box: |
31 | 31 |
|
32 |
| -:::image type="content" source="../ide/media/add-method-wizard.png" alt-text="Screenshot of Add method wizard"::: |
| 32 | +:::image type="content" source="../ide/media/add-method-wizard.png" alt-text="Screenshot of Add method wizard with the method name field set to aMethod and the return type set to HRESULT. In the Parameters section, two parameters are defined: int x, and bool clip"::: |
33 | 33 |
|
34 | 34 | ### Names
|
35 | 35 |
|
36 | 36 | - **Method name**
|
37 | 37 |
|
38 |
| - Sets the method name. Provide your own method name. |
| 38 | + Provide the method name. |
39 | 39 |
|
40 | 40 | - **Return type**
|
41 | 41 |
|
42 |
| - The data type returned by the method. Provide your own return type or select from the list. |
| 42 | + Type the return type or select it from the drop-down list. |
43 | 43 |
|
44 |
| -- **Parameter type** |
45 |
| - |
46 |
| - Sets the data type of the parameter. You can type it with parameter name. |
47 |
| - |
48 |
| -- **Parameter name** |
| 44 | +- **Parameters** |
49 | 45 |
|
50 |
| - Sets the name of a parameter. Select **+** to add the parameter to the list of parameters. |
| 46 | + Displays the method's parameters, modifiers, and types. The wizard updates the **Parameters** list as you add parameters. |
51 | 47 |
|
52 |
| -- **+** |
| 48 | + **+** |
53 | 49 |
|
54 |
| - Adds the parameter to the list of parameters. Specify the parameter name and its type in **Parameters**. |
| 50 | +Add a parameter. In **Parameters**, type the parameter type, name, and any modifiers. For example, `int x`, and choose **OK**. |
55 | 51 |
|
56 | 52 | - **x**
|
57 | 53 |
|
58 |
| - Removes the selected parameter from the **Parameters** list. |
| 54 | + Remove the selected parameter from the **Parameters** list. |
59 | 55 |
|
60 |
| -- **Parameters** |
| 56 | +- **Pencil icon** |
61 | 57 |
|
62 |
| - Displays all of the methods parameters, modifiers, and types. The wizard updates the **Parameters** list as you add parameters. |
| 58 | + Edit the selected parameter. |
0 commit comments