MISRA Discussion Forums
Rule 10-3-1 - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18)
+--- Forum: MISRA C++:2008 rules (https://forum.misra.org.uk/forumdisplay.php?fid=19)
+---- Forum: 6.10 Derived classes (C++) (https://forum.misra.org.uk/forumdisplay.php?fid=139)
+---- Thread: Rule 10-3-1 (/showthread.php?tid=1018)



Rule 10-3-1 - wcarl - 17-01-2014

There shall be no more than one definition of each virtual function on each path through the inheritance hierarchy.

If I'm interpreting this rule correctly, once you define a virtual function for a derived class with the virtual base class as an ancestor, no more derivations in the chain can override the first definition.

This would seem to cripple a key advantage of using classes and an object-oriented design.

Isn't it pretty common to override a virtual member function in a child class even if the parent class has provided a different definition? Please explain.


Re: Rule 10-3-1 - misra cpp - 05-10-2015

This is intentional and, as stated in the text for the rule, is done to increase clarity for review and maintenance. It would be acceptable to deviate if a more complex hierarchy is required.

We will review this when working on the next version of MISRA C++.


Re: Rule 10-3-1 - dg1980 - 15-11-2017

Under the impression of MISRA Compliance i came up with two deviation permits so far:
  • Reliability (Fault tolerance): Implementing default/fallback behaviour/strategy for polymorphic types
  • Maintainability (Reusability): Extending base class functionality for polymorphic types



Re: Rule 10-3-1 - misra cpp - 17-01-2018

Thanks