Lab 6 -- C++ Classes

Answer Sheet

Exercise 1

Describe the difference between procedural-oriented programming and object-oriented programming.


Exercise 2

a) Describe the difference between a pure and a hybrid programming language.

b) An example of a pure OOP programming language.

c) An example of a hybrid OOP programming language.

Exercise 3

A VCR can be thought of as an example of an object.

a) Name some "data items or data features" which come standard with a simple VCR?

b) Name some "operations" which a simple VCR would perform?

Exercise 4

The VCR can be used as an example of data encapsulation. Explain.

Exercise 5

Consider the VCR again.

a) Describe an operation in which information hiding is being used.

b) Give an operation which would be in the public interface of the VCR.

Exercise 6

Consider a "date" object.

a) What data should be included in a date object?

b) What methods should be included to allow us to initialize a date, to display the date in the form 12/25/96, or to display the date in the form Month day, Year? Use the "clock" as an example to go by. (We won't have a method to increment the date in our "date" object.)

Exercise 7

{ Script }

Exercise 8

{ Script }

Exercise 9

{ Script }

Exercise 10

The above example was a very simple example of a main program utilizing the Clock class. For a slightly more complicated example of a main program utilizing the Clock class, load the file main6a.cc from the 2170 account to your account. Both the main function and the implementation functions for the Clock class must be compiled. Since they are in separate files, a slight variation of the compilation command is required. To compile this program, type:

aCC inlab6a.cc main6a.cc -o inlab6a

Run the program (the executable is contained in inlab6a). Read the program and make sure you understand the code.
What does the program do?

Exercise 11

{ Script }

----- End of Lab 6 - C++ Classes -----
Complete the Exercises on the Answer Sheet.
Turn in the Answer Sheet and the printouts required by the exercises.