A ``++virtual++`` function has an implementation that _may_ be replaced in a child class. A pure ``++virtual++`` has no implementation, and _must_ be implemented in child classes.


Hiding a base class implementation with a "pure implementation" (``++=0++``) is sure to confuse extenders, who may not be aware of the base class' implementation. Instead, they'll see there's no implementation in the class they're extending and assume that none exists. When that base class implementation contains crucial functionality such as freeing resources, this could cause future users of the class to introduce bugs.


This rule raises an issue if a pure virtual function overrides a virtual function that is not pure.


== Noncompliant Code Example

----
struct A {
  virtual void func1();
  virtual void func2() = 0;
};

struct B : A {
  virtual void func1() = 0; // Noncompliant; override non-pure virtual
  virtual void func2() = 0; // Compliant; but useless
};
----


== Compliant Solution

----
struct A {
  virtual void func1();
  virtual void func2() = 0;
};

struct B : A {
  virtual void func1(); // Compliant; non-pure virtual
};
----


== See

* MISRA {cpp}:2008, 10-3-3 - A virtual function shall only be overridden by a pure virtual function if it is itself declared as pure virtual.


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

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