|
|
By Alex, on June 27th, 2007
In a previous lesson, you learned that you can use structs to aggregate many different data types into one variable. However, structs are not the only aggregate data type. An array is an aggregate data type that lets you access multiple variables through a single name by use of an index. In C++, all . . . → Read More: 6.1 — Arrays (Part I)
By Alex, on June 26th, 2007
Break
Although you have already seen the break statement in the context of switch statements, it deserves a fuller treatment since it can be used with other types of loops as well.
The break statement causes a switch statement, while loop, do while loop, or for loop to terminate. In the context of a . . . → Read More: 5.8 — Break and continue
By Alex, on June 25th, 2007
By far, the most utilized looping statement in C++ is the for statement. The for statement is ideal when we know exactly how many times we need to iterate, because it lets us easily declare, initialize, and change the value of loop variables after each iteration.
The for statement looks pretty simple:
for (init-statement; . . . → Read More: 5.7 — For statements
By Alex, on June 25th, 2007
One interesting thing about the while loop is that if the loop condition is false, the while loop may not execute at all. It is sometimes the case that we want a loop to execute at least once, such as when displaying a menu. To facilitate this, C++ offers the do while loop:
do . . . → Read More: 5.6 — Do while statements
By Alex, on June 25th, 2007
One of the amazing things about working in a department with other coders is that you consistently see the same mistakes being made day after day, month after month, year after year. Whether it’s due to general timidity, fear of criticism being taken personally, lack of a formal review process, or a company . . . → Read More: Six language-independent ways to write better code
|
|