- Class declarations must end with a semicolon.
- The accessor GetAge()is private. Remember: All class members are private unless
you say otherwise. - You can’t access itsStationdirectly. It is private.
You can’t call SetStation()on the class. You can call SetStation()only on
objects.
You can’t initialize myOtherTVbecause there is no matching constructor.
Day 7....................................................................................................................
Quiz ................................................................................................................
- Separate the initializations with commas, such as
for (x = 0, y = 10; x < 100; x++, y++).
2.gotojumps in any direction to any arbitrary line of code. This makes for source
code that is difficult to understand and, therefore, difficult to maintain. - Yes, if the condition is false after the initialization, the body of the forloop will
never execute. Here’s an example:
for (int x = 100; x < 100; x++) - The variable xis out of scope; thus, it has no valid value.
- Yes. Any loop can be nested within any other loop.
- Yes. Following are examples for both a forloop and a whileloop:
for(;;)
{
// This for loop never ends!
}
while(true)
{
// This while loop never ends!
} - Your program appears to “hang” because it never quits running. This causes you to
have to reboot the computer or to use advanced features of your operating system
to end the task.
Exercises ........................................................................................................
- The following is one possible answer:
for (int i = 0; i< 10; i++)
{
for ( int j = 0; j< 10; j++)
832 Appendix D
32 0672327112_app_d.qxd 11/19/04 12:30 PM Page 832