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
 Feature Requests
 Refactoring: Renaming a base class
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

xMRi
Tomato Guru

Germany
315 Posts

Posted - May 11 2015 :  03:09:27 AM  Show Profile  Reply with Quote
Let us assume I have a class A derived from class B


class A: public B
{
...
   virtual void SomeFunc();
}; 


void A:SomeFunc()
{
    B:SomeFunc();
}


Now I want to change the base class. Yes this is a rare case. But sometimes you need to get an extra layer in the class hierarchy. And than you need to change the base class.


In my case a dialog was derived from CDialog. But I need CDialogEx...
Finding all locations is tricky. Missing one means that the extra functionality of CDialogEx doesn't get in effect.

But renaming B here is not remaing the classd B. Is is chaning the class name in the class declaration and in the function definition!

Martin Richter [rMVP] WWJD http://blog.m-ri.de
"A well-written program is its own heaven; a poorly written
program is its own hell!" The Tao of Programming

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - May 11 2015 :  08:26:02 AM  Show Profile  Reply with Quote
quote:
But renaming B here is not remaing the classd B. Is is chaning the class name in the class declaration and in the function definition!

Do you mean that if you trigger VA rename from the line

class A: public B

it will not find the class declaration for class B?

When I trigger rename there, it finds and renames all 3 instances of B in the following sample code. But I think I just don't understand your question.

class B {
public:
	virtual void SomeFunc();
};

class A : public B
{
   virtual void SomeFunc();
}; 


void A::SomeFunc()
{
    B::SomeFunc();
}


To change what class "class A" is derived from, you would need to rename at all places when you call the parent. Wouldn't a simple find and replace work? Searching for CDialog:: and replacing with CDialogEx:: and taking a look at all found instances before you proceed with the replace?
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