Partager via


Overriding a Virtual Function (Visual C++)

 

The latest version of this topic can be found at Overriding a Virtual Function (Visual C++).

You can override virtual functions defined in a base class from the Visual Studio Properties window.

To override a virtual function in the Properties window

  1. In Class View, click the class.

  2. In the Properties window, click the Overrides button.

    Note

    The Overrides button is available when you select either the class name in Class View or when you click within the source window.

    The left column lists the virtual functions. If the name of a virtual function also appears in the right column, then an override has already been implemented.

  3. If the function has no override, then click the cell in the right column in the Properties window to display the suggested name of the function override as <add>FuncName.

  4. Click the suggested name to add stub code for the function.

  5. To edit an overriding function, double-click the name of the function in Class View and edit the code in the source window.

To remove an override, click the override function name in the right column and select <delete>FuncName. The function's code is commented out.

See Also

Adding Functionality with Code Wizards
Adding a Class
Adding a Member Function
Adding a Member Variable
MFC Message Handler
Navigating the Class Structure