Rule 3-4-1 and classes

Moderators: david ward, misra cpp

Post Reply
drstaiger
Posts: 2
Joined: Thu Oct 13, 2011 3:04 am
Company: Axivion GmbH

Rule 3-4-1 and classes

Post by drstaiger » Wed Dec 21, 2016 10:50 am

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?

misra cpp
Posts: 145
Joined: Mon Jun 02, 2008 1:55 pm
Company: MISRA

Re: Rule 3-4-1 and classes

Post by misra cpp » Tue Jan 24, 2017 9:54 am

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
Posted by and on behalf of
the MISRA C++ Working Group

Post Reply

Return to “6.3 Basic concepts (C++)”