Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Refactor: Override of a virtual function

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
mbobka Posted - Jun 28 2006 : 09:56:29 AM
For instance:


class CBaseClass {
public:
    virtual void FuncA();
    virtual void FuncB() = 0;
};

class CDerivedClass: public CBaseClass {
public:

};


It would be cool, if Refactor will have option to override any virtual (or not only virtual fuctions of CBaseClass) in CDerivedClass.
12   L A T E S T    R E P L I E S    (Newest First)
support Posted - Jan 24 2011 : 4:04:57 PM
case=1505 is implemented in build 1840
feline Posted - Jul 15 2006 : 11:35:49 AM
i will put this plugin on my list of things to have a look at. there are no screen shots on the article to help me visualise what it is going to do, or how it is going to do it.
ralfz Posted - Jul 13 2006 : 2:17:57 PM
One example for a -well, at least for me- good solution handling the override of virtual functions, is an old Addin for VS6 called "WizGen". It can be found on Codeproject at:

http://www.codeproject.com/macro/wizgen.asp

It assumes, that the current active .h file in VS editor contains the "target" class declaration (the class deriving) and shows a dialog with base class functions to select from. It is possible to select from a combobox the base class to derive from, if multiple bases.

Please take a look at this addin. I always missed that, when working in VS environment > 6.0.

Probably VAX already has all the information needed for a similar dialog. For me personaly, such a feature would be another, if not THAT "Killer-super-cool-Feature" in VAX.

This Addin made it even possible to have a "Class-wizzard" like behavior in VS6, not for just MFC, but for 3rd-party libraries, which should be "Stable includes" in VAX terms.
feline Posted - Jul 02 2006 : 1:40:34 PM
it came up in another thread, after i posted here. still, good to have these things confirmed.
mbobka Posted - Jul 01 2006 : 11:49:16 AM
"override" is a new keyword in VS2005. Can be applied in CRL/C++ and plain/C++.
feline Posted - Jul 01 2006 : 11:46:04 AM
interesting. i have put a note on the feature request about this, and saying that you have posted a good example here.

in your sample code i presume the word "override" is just a comment or marker, and is not supposed to compile?
mbobka Posted - Jun 30 2006 : 02:08:43 AM
when I call refactor for ISomeCoolInterface2, then refactor adds function and preserves interface visibility:

class CObjectWithTwoInterfaces:
   public ISomeCoolInterface1,
   protected ISomeCoolInterface2
{
public:
public:  // ISomeCoolInterface1
  void Function1() override;
protected:  // ISomeCoolInterface2
  void Function10() override;
  void Function11() override;
  void Function12() override;
};



I think there must be two Autotext template: for entire interface implementation, and second for a implemented function (I want use "override" specifier for the function)
mbobka Posted - Jun 30 2006 : 02:07:37 AM
I think here needed two ways to be implemented.
1. Overriding any virtual funciton
2. Implementing all pure virtual functions of specified base class (for fast interfaces implementation)

First way, requires list of functions one of which you want to implement.
Second way can be done absolutely automatically.

I want to describe as I see second way implementation.
We have:

class ISomeCoolInterface1 {
public:
  virtual void Function1() = 0;    // this function must be implemented through autoimplementation
  virtual void Function2() {};     // this function not be implemented through autoimplementation

  void Function3();     // this function never be overriden by refactor
}

class ISomeCoolInterface2 {
public:
   virtual void Function10() = 0;
   virtual void Function11() = 0;
   virtual void Function12() = 0;
}

class CObjectWithTwoInterfaces:
   public ISomeCoolInterface1,
   protected ISomeCoolInterface2
{
public:

};



When I hover on ISomeCoolInterface word in CObjectWithTwoIntefaces declaration VAX should show "down arrow icon" with item in menu "Override pure virtual functions of class ..." (or smth like this)

When I call "Override pure virtual functions of class ..." then the class declaration will be like this:

class CObjectWithTwoInterfaces:
   public ISomeCoolInterface1,
   protected ISomeCoolInterface2
{
public:
public:  // ISomeCoolInterface
  void Function1() override;
};


--- continued below
bugfix Posted - Jun 29 2006 : 02:11:10 AM
If you decide to do it please make sure that it'll work w/ template classes as base too, e.g. ATL/WTL.

-bugfix
jpizzi Posted - Jun 28 2006 : 10:51:39 PM
Having used frameworks, too, I can see the potential for a long list. However, if the list was triggered explicitly (for example, a right-click, or a hot key), I can't see how it is worse than having no list at all. The list could be restricted to virtual methods, with pure virtuals listed first (a suggestion; I haven't thought this part through). Especially on classes that have methods with numerous overrides, I think this would be especially helpful, as getting the correct parameter list in the override sometimes poses problems.

I added a request.

case=1505

Note that my suggestion was that this be from an explicit request from the user, and that the user must select the method to override. Nothing automatic up until that point. After that, add the stub and declaration.

(edit by feline: fix case number)
feline Posted - Jun 28 2006 : 4:47:41 PM
the immediate problem here is that we have to stop and ask the user questions. we cannot simply provide bodies for all such functions, not even abstract functions. after all, derived classes are still going to be abstract.

the current approach is to keep a very low profile, and to avoid asking lots of questions.

i do a lot of work with the Qt framework, and when developing my own GUI components (e.g. a dialog) i will derive myself a class from QDialog, which has lots of virtual functions, to allow me to override any specifics i need to. most of the time i never bother.

applying this thinking to this case i could end up with a list of 20, 30, 50 functions to pick through, perhaps more for some cases.

the flip side is simple data classes, with one or two abstract functions that you always implement.

some of the time i see a lot of appeal to this idea, but other times i can see how this could be quite unhelpful.

i am wondering if there is some sensible way to organise, or hide the GUI for this. any ideas or suggestions based on experience with other products?
pogothemonkey Posted - Jun 28 2006 : 10:43:35 AM
I love this functionality in Intellij.

It knows which functions are in the superclass, in the subclass I can open a windows that shows me all the functions in the superclass I can overide and the ones that need to be overridden (pure virtual). Next you Select the ones that you want to implement and it will insert the correct function body into the code.

This is exceptionally helpful with pure virtual functions. Moving to C++ it would be great if it inserts the Declaration and a Stump Definition at the same time

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000