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
Is this job good for future? can do this job post grduate student?
What does I oop mean?
Why do we use class?
write string class as your own class in java without using any built-in function
What is object and class in oops?
Why do we use class in oops?
What is the importance of oop?
What are benefits of oop?
What is persistence in oop?
What are the features of oop?
What is encapsulation in simple terms?
What is a class oop?
What is the types of inheritance?
How do you achieve runtime polymorphism?
What is encapsulation example?