The use of ``++virtual++`` base classes can introduce a number of undefined and potentially confusing behaviours. Therefore, a base class shall only be declared ``++virtual++`` if that base class is to be used as a common base class in a diamond hierarchy.


== Noncompliant Code Example

----
class A {};
class B1: public virtual A {}; // Compliant, A is a common base for C
class B2: public virtual A {}; // Compliant, A is a common base for C
class C: public B1, B2 {};
class D: public virtual A {}; // Noncompliant, D is not part of a diamond-shaped hierarchy.
----


== See

* MISRA {cpp}:2008, 10-1-2 - A base class shall only be declared virtual if it is used in a diamond hierarchy.


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

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