BlockBlock statement. Normally contains other statements. Begins and ends with curly braces. For example: Code Block |
---|
void func() { // block
} |
Case LableRepresents a case or default label in a switch statement. For example: Code Block |
---|
void func(int i) {
switch(i) {
case 1: // Case Label
break;
case 3: // Case Label
default: // Case Label
break;
}
} |
SimpleA statement that does not fall into any other statement category. The simple statement's body usually contains an expression. For example: Code Block |
---|
void func(int & i) {
i++; // Simple statement
} |
EmptyAn empty ; statement. For example: Code Block |
---|
void func() {
if(true); // Empty statement
} |
breakBreak statement. For example: Code Block |
---|
bool bar();
void func() {
while(1) {
if (bar()) {
break; // break
}
}
} |
caseCase statement. For example: Code Block |
---|
void func(int i) {
switch(i) {
case 1: { break; } // case
case 2: { break; } // case
}
} |
catchCatch statement used for exception handling. For example: Code Block |
---|
void bar();
void func(int i) {
try {
bar();
} catch (...) { // catch
}
} |
continueContinue statement used in loops. For example: Code Block |
---|
bool bar(int);
void func(int i) {
while(i--) {
if (bar(i)) {
continue; // continue
}
}
} |
defaultDefault statement used inside a switch statement. For example: Code Block |
---|
void func(int i) {
switch(i) {
case 1: { break; }
case 2: { break; }
default: { break; } // default
}
} |
do whjilewhileDo while loop statement. For example: Code Block |
---|
void func(int i) {
do { // do while
i--;
} while (i);
} |
forFor loop statement. For example: Code Block |
---|
void bar();
void func() {
for (int i = 0; i < 10; i++) { // for
bar();
}
} |
for rangeRange-based for loop statement. For example: Code Block |
---|
void bar();
void func() {
for (auto iterator : range_expr) { // for
bar();
}
} |
gotoGoto statement. For example: Code Block |
---|
void func(bool done) {
if (done) {
goto end; // goto
}
end:
} |
ifIf statement. For example: Code Block |
---|
void func(bool done) {
if (done) { // if
return;
}
} |
returnReturn statement. For example: Code Block |
---|
int func() {
return 0; // return
} |
switchSwitch statement. For example: Code Block |
---|
void func(int i) {
switch(i) { // switch
case 1: { break; }
case 2: { break; }
default: { break; }
}
} |
tryTry statement. For example: Code Block |
---|
void bar();
void func(int i) {
try { // try
bar();
} catch (...) {
}
} |
whileWhile statement. For example: Code Block |
---|
void func(int i) {
while (i--) { // while
}
} |
|