Share via


Overriding a Virtual Function

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

Tasks

Adding a Member Function

Adding a Member Variable

Concepts

Adding Functionality with Code Wizards

Adding a Class

Adding an MFC Message Handler

Reference

Navigating the Class Structure