Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Create member functions in the Class Definition
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Kram
Junior Member

Germany
16 Posts

Posted - Oct 08 2021 :  12:42:37 PM  Show Profile  Reply with Quote
Is there an option to tell the Create Method feature to create the new member function within the class definition and not outside the class using the scope resolution operator?

B00ting, please wait...

feline
Whole Tomato Software

United Kingdom
18750 Posts

Posted - Oct 08 2021 :  12:49:48 PM  Show Profile  Reply with Quote
I am going to need to know what you are doing to be able to answer properly.

Sitting in a header file, with a simple class, I placed the caret into the class name, at the top of the class declaration, and use Alt-Shift-Q to open VA's refactoring context menu. From here I selected "Add Member..." and added a new member function to the class.

VA inserted this into the class declaration, complete with its empty body. Which seems to be what you are after, but I assume not what you are getting.

zen is the art of being at one with the two'ness
Go to Top of Page

Kram
Junior Member

Germany
16 Posts

Posted - Oct 08 2021 :  1:30:41 PM  Show Profile  Reply with Quote
There are three files: class header, class implementation and an other source file.

The other source file uses a variable that is a class from the header.

If I try to call a member function that does not exist there is a red squiggle and I have the Create Method <name method> option available from Alt-Shift-Q. This creates the implementation outside of the class.

As a second issue, I have just notice that invalid code is created if I try to change the name of the new member function from within the dialog.

B00ting, please wait...
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18750 Posts

Posted - Oct 08 2021 :  1:54:46 PM  Show Profile  Reply with Quote
OK, first issue first. I think I am seeing the same behaviour, and there is a simple "fix".

I have a class, declared in "test_simple.h", with the implementations in "test_simple.cpp", class called "simpleTestClass"

In a different file I have the function:

void usingSimpleClass()
{
	simpleTestClass localFoo;
	localFoo.NewMember(34, 23);
}

triggering "Create Method" on "NewMember" gives me the create method dialog. When I use this the declaration goes into the header file and the implementation into the cpp file. In the cpp file I can now place the caret into the method name and trigger "Move Implementation to Class Declaration", which does exactly that.

The idea behind VA's refactoring commands is to have fairly simple and well defined actions that can be chained together to achieve your final result. So this is done in two steps rather than asking, during the creation, where you want the implementation to be placed.

I am not seeing any obvious problems renaming the new function in this example.

I used undo to get rid of the created method, created it again, and renamed it to be "NewMemberOrange" in the dialog. This created valid code, confirmed by compiling it successfully. The unknown method call failed, but that was expected.

Can you reproduce the invalid code easily and on demand?

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000