Table of content
WholeTomato

Add Similar Member

Code generation with Add Similar Member is a convenient way to add a method or member variable—one that is similar to an existing member—to a class. The command is available from any reference to a member, so you can add members without interrupting your normal flow of editing, and without the typical copy-and-edit associated with simple additions.

Access

Move to the reference to a member—not its class—and select Add Similar Member from the Quick Action and Refactoring menu (Shift+Alt+Q), or context menu of the text editor (Right-Click or Shift+F10).

You can also invoke Add Similar Member from the context menu of the VA Outline, when the current selection is a member of a class.

After you invoke Add Similar Member, a dialog opens containing the signature of the existing member.

Update the signature, including member name and parameter list, as desired.

Accept the dialog and the method or member variable is added to the class containing your existing member, near the existing member. If you add a member from a base class, the member is added to the base class, not the current class.

Add Similar Member creates only a stub for the new member; it does not copy the body of the existing methods.

In C/C++, if you add a method, it is left in the appropriate header file for inline execution. If you prefer the implementation in a source file, following Add Similar Member with Move Implementation to Source File, which is also available in a refactoring menu.

After the move, your implementation exists near the implementation of your original member.

Undo

Press UNDO once to revert all changes made by Add Similar Member.

Visual C++ 6.0

Press UNDO multiple times.

Format

You can modify the format of new methods by editing the VA Snippets associated with Create Implementation. There are separate VA Snippets for separate programming languages.

Navigation

Use the Navigate commands of Visual Assist to jump between a header file and source file after Add Similar Member or Move Implementation to Source File. Immediately after either command, Alt+Left and Alt+Right jump between a header file and source file.

System Directories

Add Similar Member is not available on classes found using system directories, e.g. from MFC or 3rd party libraries.