06.06.2015 Views

C++ Coding Standard Specification - CERN

C++ Coding Standard Specification - CERN

C++ Coding Standard Specification - CERN

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>C++</strong> <strong>Coding</strong> <strong>Standard</strong><br />

<strong>Specification</strong><br />

2 Naming Version/Issue: 1.1/5<br />

link the program because of name clashes. You can avoid that by declaring and defining<br />

names (that would otherwise be global) inside namespaces.<br />

Example:<br />

A namespace is a declarative region in which classes, functions, types and templates can be<br />

defined.<br />

namespace Emc {<br />

}<br />

class Track { ... };<br />

// ...<br />

A name qualified with a namespace name refers to a member of the namespace.<br />

Emc::Track electronTrack;<br />

A using declaration makes it possible to use a name from a namespace without the scope<br />

operator.<br />

using Emc::Track;<br />

Track electronTrack;<br />

// using declaration<br />

It is possible to make all names from a namespace accessible with a using directive.<br />

using namespace Emc;<br />

Track electronTrack;<br />

Array allTracks;<br />

// using directive<br />

// Emc::Track electronTrack;<br />

// Emc::Array allTracks;<br />

The following items could appear rather arbitrary. The importance of these conventions is<br />

simply in fostering a common style and naming across a wide community of programmers.<br />

The benefit is an increase in the readability and maintainability of the produced code,<br />

especially when compared to a situation were each programmer adopts an own naming<br />

convention.<br />

NC3<br />

Start class names, typedefs and enum types with an uppercase letter.<br />

Example:<br />

class Track;<br />

typedef vector TrackVector;<br />

enum State { green, yellow, red };<br />

Source<br />

Status<br />

9.RN, 11.GN, R11, ARN6<br />

Common<br />

page 10<br />

FINAL

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!