Anonymous user
Control Structures: Difference between revisions
→[[C plus plus|C++]]
m (→if-then-else) |
|||
Line 73:
==[[C plus plus|C++]]==
=== Run-Time Control Structures ===
===if-then-else===▼
==== for ====
'''Compiler:''' [[GCC]] 3.3.4
#include <iostream>
int main()
{
int i = 1;
// Loops forever:
for(; i == 1;)
std::cout << "Hello, World!\n";
}
==== goto ====
'''Compiler:''' [[GCC]] 3.3.4
#include <iostream>
int main()
{
LOOP:
std::cout << "Hello, World!\n";
goto LOOP;
}
Note that this may also be used in conjunction with other forms of branching.
▲====if-then-else====
'''Compiler:''' [[GCC]] 4.1.2
int main (void) {
Line 91 ⟶ 119:
}
====switch====
'''Compiler:''' [[GCC]] 4.1.2
Line 113 ⟶ 141:
====while====
'''Compiler:''' [[GCC]] 4.1.2
int main (void) {
Line 125 ⟶ 153:
}
====do-while====
'''Compiler:''' [[GCC]] 4.1.2
int main (void) {
Line 136 ⟶ 164:
} while ( condition );
}
=== Compile-Time Control Structures ===
==== Preprocessor Techniques ====
#ifdef, #ifndef, etc..
==== Template Metaprogramming Techniques ====
Template metaprogramming techniques.
==[[OCaml]]==
|