TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
C++ Coding Standard
Search

Rule:  STY#011Checked automatically with code checker

This rule is Obsolete
Synopsis:In declarations, attach the & or * token to the type name instead of the object name
Language:C++
Severity Level:10
Category:Style


Description:

In a declaration, the * token specifies that the variable has pointer type. Therefore, the * token should rather be suffixed to the type name, instead of prefixed to the object name. Note that [OLC#010] ensures that this can never lead to confusion in declaration statements.

In a declaration, the & token specifies that the variable has reference type. Therefore, the & token should rather be suffixed to the type name, instead of prefixed to the object name. Note that [OLC#010] ensures that this can never lead to confusion in declaration statements.

example:

int    *mrc_ptr;   // not recommended
int*   mrcpp_ptr;  // okay, well done: emphasize that the type is int*

int    &mrc;       // not recommended
int&   mrcpp;      // okay, well done: emphasize that the type is int&


Literature References:
Ellemtel Rec. 26