Wiki

Options

Case Status
Log In

Wiki

Options

 
Whole Tomato Software - Home
  • RSS Feed

Implement Interface / Virtual Methods

Quickly generate method stubs for methods of an interface or virtual methods of a base class  in C++ or C#. Access this feature from a refactoring menu when on the class you wish to implement. Inserted stubs contain code taken from a VA Snippet, typically code to throw an unimplemented exception and remind a developer to implement functionality.

Implement Interface / Virtual Methods descends into inherited classes, so methods from base classes of multiple depths can be implemented.

Access

Open the Quick Action and Refactoring menu (Shift+Alt+Q) from a class that is derived from a base class. Select "Implement Virtual Methods".

Select methods to implement. Methods already implemented are unavailable.

Methods are implemented using a language-dependent VA Snippet, Create from Usage.

Implementing Interfaces

If you implement methods of an interface class, all methods are implemented without an intervening dialog.

If a base class has pure virtual methods, and is therefore an interface, the dialog to select methods opens with the pure virtual methods checked, and non-pure virtual methods unchecked.

In a scenario with pure virtual methods, only the pure virtual methods are checked by default.

Multiple Inheritance

To implement methods from more than one inherited class or interface, invoke Implement Interface / Virtual Methods from the current class name, not from an individual interface or base class.

To implement methods from a single inherited class or interface, invoke Implement Interface / Virtual Methods from the name of a base class, not from the current class name.

Complex Scenarios

In a mixed scenario of multiple inheritance, with abstract and concrete classes, Visual Assist lets you select from a list in which only the interface methods are selected by default.

Filtering

If the list of methods to implement/override is long, use filtering to reduce its size. 

Filtering does not affect the states of checked entries so you can filter repeatedly to find a disparate set of methods.

As possible in other dialogs of Visual Assist, use multiple strings, negative filtering, and dot filtering to reduce the size of the list.

If you want to search names and parameter lists, disable the option to filter by name only.

Sorting

By default, methods are sorted in the order they appear in classes. If you wish methods within each class to be sorted by name, enable the respective sort option.

Override Identifier

In C++11, you can append "override" to a virtual function declaration and tell the compiler that you want to override a virtual method inherited from a base class. If the virtual method does not exist in the base class, or has a different signature, the compiler raises an error and the compilation fails.

You can insert "override" where applicable via a setting in the options dialog for Visual Assist.

Default Method Body

Edit the language-dependent VA Snippet for Create From Usage Method Body to change the default method body created by Implement Interface / Virtual Methods.

The following is the default VA Snippet for Create From Usage Method Body in C++.