Overriding a function just to call the overridden function from the base class without performing any other actions can be useless and misleading.


There are cases when it is justified, because redeclaring the function allows some side effects:

* Changing the visibility of the function in the derived class
* Preventing the base class function from being hidden by an overload added in the derived class (a using declaration could have the same effect)
* To resolve ambiguities in cases of multiple inheritance
* To make an inherited function final

This rule raises an issue when an override which is not in one of the aforementioned situation only calls the overridden function, directly forwarding its arguments.

== Noncompliant Code Example

----
class Base {
public:
  virtual void f();
};

class Derived : public Base {
public:
  virtual void f() {
    Base::f(); // Noncompliant
  }
};
----

== Compliant Solution

----
class Base {
public:
  virtual void f();
};

class Derived : public Base {
};
----
or

----
class Base {
public:
  void f();
};

class Derived : public Base {
private: // change of visibility
  virtual void f() {
    Base::f();
  }  
};
----
or

----
class Base {
public:
  void f();
};

class Derived : public Base {
public:
  void f(int i);
  void f() { // Prevents hiding by f(int)
    Base::f();
  }  
};
----

or


----
class Base {
public:
  virtual void f();
};

class Derived : public Base {
public:
  void f() final { // final
    Base::f();
  }
};
----

ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]
