Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions cppguide.html
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ <h3 id="Class_Comments">
</div>
<div class="stylebody">
<pre>
// Iterates over the contents of a GargantuanTable. Sample usage:
// Iterates over the contents of a GargantuanTable. Sample usage:
// GargantuanTableIterator* iter = table-&gt;NewIterator();
// for (iter-&gt;Seek("foo"); !iter-&gt;done(); iter-&gt;Next()) {
// process(iter-&gt;key(), iter-&gt;value());
Expand Down Expand Up @@ -1195,7 +1195,7 @@ <h4 class="stylepoint_subsection">
describing what they are and what they are used for. For example:
</p>
<pre>
// The total number of tests cases that we run through in this regression test.
// The total number of tests cases that we run through in this regression test.
const int kNumTestCases = 6;
</pre>
</div>
Expand Down Expand Up @@ -1247,7 +1247,7 @@ <h4 class="stylepoint_subsection">
more readable to line them up:
</p>
<pre>
DoSomething(); // Comment here so the comments line up.
DoSomething(); // Comment here so the comments line up.
DoSomethingElseThatIsLonger(); // Two spaces between the code and the comment.
{ // One space before comment when opening a new scope is allowed,
// thus the comment lines up with the following comments and code.
Expand Down Expand Up @@ -1354,7 +1354,7 @@ <h3 id="TODO_Comments">
</p>
<div>
<pre>
// TODO(kl@gmail.com): Use a "*" here for concatenation operator.
// TODO(kl@gmail.com): Use a "*" here for concatenation operator.
// TODO(Zeke) change this to use relations.
</pre>
</div>
Expand Down Expand Up @@ -1545,7 +1545,7 @@ <h3 id="Function_Declarations_and_Definitions">
Functions look like this:
</p>
<pre>
ReturnType ClassName::FunctionName(Type par_name1, Type par_name2) {
ReturnType ClassName::FunctionName(Type par_name1, Type par_name2) {
DoSomething();
...
}
Expand All @@ -1554,7 +1554,7 @@ <h3 id="Function_Declarations_and_Definitions">
If you have too much text to fit on one line:
</p>
<pre>
ReturnType ClassName::ReallyLongFunctionName(Type par_name1, Type par_name2,
ReturnType ClassName::ReallyLongFunctionName(Type par_name1, Type par_name2,
Type par_name3) {
DoSomething();
...
Expand Down Expand Up @@ -1726,7 +1726,7 @@ <h3 id="Function_Calls">
comment:
</p>
<pre>
bool retval = DoSomething(scores[x] * y + bases[x], // Score heuristic.
bool retval = DoSomething(scores[x] * y + bases[x], // Score heuristic.
x, y, z);
</pre>
<p>
Expand Down Expand Up @@ -1836,7 +1836,7 @@ <h3 id="Conditionals">
using one.
</p>
<pre class="badcode">
if(condition) { // Bad - space missing after IF.
if(condition) { // Bad - space missing after IF.
if (condition){ // Bad - space missing before {.
if(condition){ // Doubly bad.
</pre>
Expand All @@ -1854,7 +1854,7 @@ <h3 id="Conditionals">
This is not allowed when the if statement has an <code>else</code>:
</p>
<pre class="badcode">
// Not allowed - IF statement on one line when there is an ELSE clause
// Not allowed - IF statement on one line when there is an ELSE clause
if (x) DoThis();
else DoThat();
</pre>
Expand Down Expand Up @@ -1970,7 +1970,7 @@ <h3 id="Loops_and_Switch_Statements">
while (condition) continue; // Good - continue indicates no logic.
</pre>
<pre class="badcode">
while (condition); // Bad - looks like part of do/while loop.
while (condition); // Bad - looks like part of do/while loop.
</pre>
</div>
<h3 id="Pointer_and_Reference_Expressions">
Expand Down Expand Up @@ -2071,13 +2071,13 @@ <h3 id="Return_Values">
use them in <code>x = expr;</code>.
</p>
<pre>
return result; // No parentheses in the simple case.
return result; // No parentheses in the simple case.
// Parentheses OK to make a complex expression more readable.
return (some_long_condition &amp;&
another_condition);
</pre>
<pre class="badcode">
return (value); // You wouldn't write var = (value);
return (value); // You wouldn't write var = (value);
return(result); // return is not a function!
</pre>
</div>
Expand Down Expand Up @@ -2236,7 +2236,7 @@ <h3 id="Constructor_Initializer_Lists">
or
</p>
<pre>
// When it requires multiple lines, indent 4 spaces, putting the colon on
// When it requires multiple lines, indent 4 spaces, putting the colon on
// the first initializer line:
MyClass::MyClass(int var)
: some_var_(var), // 4 space indent
Expand Down Expand Up @@ -2302,7 +2302,7 @@ <h4 class="stylepoint_subsection">
General
</h4>
<pre>
void f(bool b) { // Open braces should always have a space before them.
void f(bool b) { // Open braces should always have a space before them.
...
int i = 0; // Semicolons usually have no space before them.
// Spaces inside braces for braced-init-list are optional. If you use them,
Expand Down Expand Up @@ -2330,7 +2330,7 @@ <h4 class="stylepoint_subsection">
Loops and Conditionals
</h4>
<pre>
if (b) { // Space after the keyword in conditions and loops.
if (b) { // Space after the keyword in conditions and loops.
} else { // Spaces around else.
}
while (test) {} // There is usually no space inside parentheses.
Expand Down