Explain composition.

What will be an ideal response?


A class can contain objects of another class as data members. For example, you might create a class named Date that contains a month, day, and year, and add two Date fields to an Employee class to hold the Employee's birth date and hire date. Then you might create a class named Department that represents every department in a company, and create each Department class member to contain a supervisor, who is an Employee. When a class contains objects of another class, the relationship is called a whole-part relationship or composition. The relationship created is also called a has-a relationship because one class "has an" instance of another.

Computer Science & Information Technology

You might also like to view...

Write a function template for a function named minimum. The function will have two parameters of the same type. It returns the smaller of these (either if they are equal.)

In carrying this out, give: a) a prototype (declaration) and preconditions for the function template b) a definition for this function. c) As a part of your answer, remark on the restriction of this function template to types for which operator< defined.

Computer Science & Information Technology

A, AAAA, PTR, NS, CNAME, and MX are all examples of ______________

a. Domain names b. DNS files c. Resource records d. DNS zones

Computer Science & Information Technology

Which of the following should be considered to mitigate data theft when using CAT5 wiring?

A. CCTV B. Environmental monitoring C. Multimode fiber D. EMI shielding

Computer Science & Information Technology

Navigating folders involves deleting and moving them.

Yes No

Computer Science & Information Technology