2.8 Class Types (4)

2013-10-07 15:25:26 · 作者: · 浏览: 76

EXERCISES SECTION 2.8

Exercise 2.28: Compile the following program to determine whether your compiler warns about a missing semicolon after a class definition:

  1. class Foo {  
  2. // empty  
  3. // Note: no semicolon  
  4. int main()  
  5. {  
  6. return 0;  

If the diagnostic is confusing, remember the message for future reference.

Exercise 2.29: Distinguish between the public and private sections of a class.

Exercise 2.30: Define the data members of classes to represent the following types:

(a) a phone number (b) an address

(c) an employee or a company (d) a student at a university