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).
![](/~/media/wholetomato/kb/documentation/add-similar-member/addsimilarmembermenu.ashx?la=ru&hash=1EF009FFBB4394D1B9FB2BFA1108166D3EF67E91)
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.
![](/~/media/wholetomato/kb/documentation/add-similar-member/addsimilarmemberoutline.ashx?la=ru&hash=6F07904946F788ADA35A5054924152408D6832BB)
After you invoke Add Similar Member, a dialog opens containing the signature of the existing member.
![](/~/media/wholetomato/kb/documentation/add-similar-member/addsimilarmemberdialog1.ashx?la=ru&hash=084713799885297B5715EAFA5621DDDE39F7E07A)
Update the signature, including member name and parameter list, as desired.
![](/~/media/wholetomato/kb/documentation/add-similar-member/addsimilarmemberdialog2.ashx?la=ru&hash=6849A739C6D6CEF5F26E34A86AA49292AD623C38)
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.
![](/~/media/wholetomato/kb/documentation/add-similar-member/addsimilarmemberheader.ashx?la=ru&hash=B20D3AF4F3D1267021B0CE6B17090D902545926C)
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.
![](/~/media/wholetomato/kb/documentation/add-similar-member/addsimilarmembermove.ashx?la=ru&hash=36D5536216DF0E420BF12329E11D477C9D33E64D)
After the move, your implementation exists near the implementation of your original member.
![](/~/media/wholetomato/kb/documentation/add-similar-member/addsimilarmembersource.ashx?la=ru&hash=0AD4CA2A86F3897387AA167A6E0B45ED7FCB4ED3)
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.