views:

46

answers:

3

I have a base class that declares a virtual function, and a large set of subclasses that inherit from the class, some of which may override the function. Now I need to alter the behavior of the base function (make it non virtual and move the overridable functionality to a different place), and I wonder if there's a quick way to locate all the classes that override this function (at or berfore compile time). Compiler is VC++.

Any ideas?

A: 

I suspect with the proper incantation, Doxygen can probably create a graph like that.

An easier method might be to make the function private in the base class. That should give an error message for every attempt at overriding it. It'll also give an error for every attempt to use it, but it sounds like you may need to identify those places as well.

Jerry Coffin
Doxygen by default will do this (assuming you've set it up to document all private members).
the_mandrill
+1  A: 

You can change the return type of the virtual function of the base class. Then your compiler should generate an error for the derived classes because the override is not legal (changing only the return type is not allowed.)

ltcmelo
A: 

If you have access to a proper shell: Locating all files where sub-classes are located should be easy with "grep". Searching all those files and removing the function could be done with your favourite editor and a small macro that does a search for the function name and deletes the declaration. Removing the function definition (if it ain't inline) should be similar.

pmr