MISRA Discussion Forums
Rule 3-4-1 and classes - 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.3 Basic concepts (C++) (https://forum.misra.org.uk/forumdisplay.php?fid=132)
+---- Thread: Rule 3-4-1 and classes (/showthread.php?tid=1301)



Rule 3-4-1 and classes - drstaiger - 21-12-2016

The rule's title includes "types", but the body of the rule does not specify further whether this is meant for typedefs only, or for complex classes as well.
For example, a class only used in a single function: should it be moved into the function? That would work against the typical ideas of short functions and separation of responsibilities. Could you please clarify MISRA's intention here?


Re: Rule 3-4-1 and classes - misra cpp - 24-01-2017

As currently stated you are correct, a class only used in a single function should be declared in that function.

However, you are also right that this may be undesirable. This will be reviewed for a future version