Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
3-2-4 and pure virtual functions

Rule 3-2-4 states:

Quote:An identifier with external linkage shall have exactly one definition.

This would also apply to pure virtual functions of abstract base classes. I have personally never seen anyone use that feature and gather from reading up about it that it is questionable design to supply definitions for those. In most cases, these functions would be empty and collide with rules about unused code anyway.

Was this intended or an oversight? I propose to add an exception for pure virtual functions.

Also, I propose to replace "An" with "All". Otherwise, it would be enough to add one variable somewhere and provide a definition for it.

When this was written in 2008, we were a bit lax with our use of the terms 'identifier' and 'definition'. In the version we are proposing for the next version, this has become 'An entity shall have no more than one definition' - which is hopefully clearer.

The intension is that a pure virtual function satisfies this requirement
Posted by and on behalf of
the MISRA C++ Working Group

Forum Jump:

Users browsing this thread: 1 Guest(s)