The original posts can be found at talesofcpp.blogspot.com

23 Apr, 2013

True Story: When Friendship Smothers

Episode Three tells us about friendship, and how it can be used to narrow access to a class or function. However, that's not the only thing friendship restricts, it also restricts how we may use such class or function. What follows is a concrete example of how friendship may cramp your style.

19 Feb, 2013

Episode Two: Those Whose Names shall not be Spoken

A naming convention is a set of rules for choosing the character sequence to be used for identifiers which denote variables, types and functions etc. in source code and documentation. They can be a source of enormous controversy, the kind of controversy that start wars —flame wars that is—. C++ specifies a naming convention for reserved identifiers, names that can be safely used by the implementation and standard library, and which result in undefined behavior if used in a program. Such naming convention is standard, so there shouldn't be any controversy, and any standard conformant code has to make sure it does not declare any one of those reserved names.

19 Jan, 2013

Episode One: To be or not to be const

Const-correctness is the form of program correctness that deals with the proper declaration of objects as mutable or immutable. The idea of constness is a compile-time enforced construct that indicates what a programmer should do, it communicates information about a value's intended use: whether something may or may not be modified. Embedding such intent by means of a keyword will result in clearer, easier to follow code; and if you happen to stray from the declared intent the compiler will step up and make you think twice about what you are trying to do.

← Older posts