Cancel overridden functions

Is there a command like \deprecated for example, but to denote overridden functions?

Java has an @override annotation for functions that you have redefined. I would like to do the same in C ++ so that I can see the functions of the superclass that I redefined. In the best case, the documentation page should also display all member functions of the class that are inherited, but are not explicitly overridden by hyperlinks to the functions of the superclass.

I know that there is a way to copy the documentation from the superclass method. But I do not want the entire document to be copied. I just want to know that the function is inherited. The behavior should look like an obsolete option to mark these old features with a panel.

+7
source share
2 answers

Each overridden function automatically receives a notification that has been reimplemented. For example, an overridden function in a derived class receives a "Reimplemented from MyBaseClass" notification.

It also places a notice in the base class documentation. Mentioned "Reimplemented in Test"

To show all functions, including inherited functions, you can set INLINE_INHERITED_MEMB to YES . Doxygen then copies the documentation of each inherited but not overridden function into the documentation of the derived class.

For example, when using this source:

 class TestBase { public: /** * Base class function. */ virtual void function(); /** * Another function. */ virtual void another(); }; class Test: public TestBase { public: /** * Overridden function. */ virtual void function(); }; 

And setting INLINE_INHERITED_MEMB in YES will result in the following documentation for the Derived class: (with Doxygen 1.7.6)

Member Function Documentation

virtual void TestBase::another ( ) [virtual, inherited]
Another function.

virtual void Test::function ( ) [virtual]
Derivative.
Reimplemented from the test base.

I think this is what you are looking for.

+7
source

With C ++ 11, you can use the override specifier:

 class A { virtual void jump() = 0; void talk() {} }; class B: public A { void jump() const override {...} // Error: B:: jump does Not overrides A:: jump (A::Jump is not const...) void jump() override {...} // OK: B:: jump overrides A:: jump void talk() override {...} // Error: A::talk is not virtual }; 

Original example and white paper: http://en.cppreference.com/w/cpp/language/override

0
source

All Articles