Write a program to demonstrate the use of 'Composition' in C++

Answer Posted / mahendra

Find the program below to demonstrate the composition.
first define the class called the DataBirth.
class DateOfBirth
{
public:
void UpdateDMY();
void GetDMY();
private:
int date,month,year;
};
define the Employee class.
class Employee
{
public:
void GetDetails();
void UpdateDetails();


private:
DateOfBirth BirthDate;
}
Here the EMployee class is having the object of the
DateOfBirth class as data member. With this the Employee
class is achieving the "has-a" relation with the
DateOfBorth class. In this way the Employee class can have
objects of the many calsses as members.

Is This Answer Correct ?    14 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to get the oracle certification? send me the answer

1877


What is destructor oops?

821


How to use CMutex, CSemaphore in VC++ MFC

4517


How long to learn object oriented programming?

795


Can we create object of interface?

805


What are the 4 main oop principles?

927


Describe these concepts: Polymorphism, Inheritance and Abstraction.

829


What is encapsulation in oop?

772


i=20;k=0; for(j=1;k-i;k+=j<10?4:3) { cout<

1625


Can main method override?

808


What is the real life example of polymorphism?

837


Why oops is important?

773


Why do we use oops?

749


What are properties in oop?

789


What is coupling in oop?

763