description | title | ms.date | f1_keywords | helpviewer_keywords | ms.custom | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: Add a method to an interface in a Microsoft Visual Studio C++ project |
Add a method |
03/31/2022 |
|
|
devdivchpfy22 |
Use the add method wizard 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.
Add a method to your interface:
-
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.
[!NOTE] You can also add methods to dispinterfaces. Unless the project is attributed, dispinterfaces are located under the library node.
-
Right-click the name of the interface.
-
On the shortcut menu, choose Add > Add Method.
-
In the Add Method wizard dialog box, provide the information to create the method as described in the next section.
-
Select OK to add the method.
Add a method to an interface by using the add method wizard:
:::image type="content" source="../ide/media/add-method-wizard.png" alt-text="Screenshot of Add method wizard. Method name is aMethod, return type is H RESULT. Two parameters are defined: int x, bool clip":::
-
Method name
Provide the method name.
-
Return type
Type the return type or select it from the drop-down list.
-
Parameters
Displays the method's parameters, modifiers, and types. The wizard updates the Parameters list as you add parameters.
-
+
Add a parameter. In Parameters, type the parameter type, name, and any modifiers. For example,
int x
, and choose OK. -
x
Remove the selected parameter from the Parameters list.
-
Pencil icon
Edit the selected parameter.
Add an IDL method wizard
Add an IDL MFC method wizard
Adding functionality with code wizards