wiki:CppCodingStandards

Version 3 (modified by dtodd, 10 years ago) (diff)

--

C++ Coding Standards

Overview

Below I will describes in Gory detail suggested guidelines for C++ code. These rules apply to new code: new files, new modules, new projects.

When editing an older file to fix a minor bug, etc, I think it's prudent to make small changes to the source. In this case, it will be best for readability if you use the standard that was there previously. Than includes following the established indentation, placement of curly brackets "{}", naming conventions, etc.

Obviously if the code requires a complete rewrite, then use the suggested coding standards listed below.

Here are some resources and books I like for learning C++, coding standards, and general conventions for C++. As of this writing (July 2009) C++ is scheduled for a major revision (http://en.wikipedia.org/wiki/C%2B%2B0x), and I imagine many new books will come out and make some of my original suggestions obsolete:

Resources

Bjarne Stroustrup's C++ Style and Technique FAQ: http://www.research.att.com/~bs/bs_faq2.html

Great website (For all things C++, STL, C) : http://www.cplusplus.com/

Coding Standards

Good Books

Intermediate and Advanced

Effective C++, and More Effective C++, by Scott Meyers

Beginning

C++ Primer Plus, by Stephen Prata

Coding Standards (Meta Rules)

C++ Coding Standards: 101 Rules, Guidelines, and Best Practices, by Herb Sutter and Andrei Alexandrescu.

"look upon this primarily as a set of meta-rules... and ignore this book at your peril"

  • Bjourne Strousturp

STL

  • Effective STL, by Scott Meyers
  • C++ Templates: The Complete Guide, by David Vandevoorde and Nicolai M. Josuttis

Proposed Standard