C++

profileh2o
lab16initialization_lists_.docx

Class relationships and initialization lists

Attached Files:

· ile  lab16files.tgz (705 B)

Macintosh HD:Users:Moonh:Desktop:xid-7053296_1.png

For this lab write a Report class based on the class diagram shown above. The Report class relies on both the Date class and the Time class. The Date and Time classes are attached (see link above diagram), along with a source file containing the main-function that should be used. As shown in the diagram, you must write two member functions for the Report class:

1. A six-parameter constructor. The six parameters should be in the following order: month, day, year, hour, minute, description. Use an initialziation list to pass these six parameters into the constructors of Report's private data.

2. A display function. Report's display function's output should look like:

Report date: <the report's date>

Report time: <the report's time>

Report desc: <the report's description>

There is a content overview associated with this lab: 08 Class relationships: composition. This can be found in Quizzes.

08 Class relationships: composition

Top of Form

Bottom of Form

Content

· https://learn.csuchico.edu/images/ci/sets/set01/document_on.gif

External resources

Composition, or the "has-a" relationship is one way to allow one C++ object to communicate with another. It's name comes from one class being composed of (in part) another class. This relationship is established when an object of one class is (private) data of another class.

· http://www.learncpp.com/

1. Section 10.1

2. Section 10.2

· http://www.learncpp.com/cpp-tutorial/102-composition/

· https://sites.google.com/site/gbswebportfolio/projects/c-composition-example