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
What are the benefits of oop?
Explain virtual inheritance?
What is pointer in oop?
What is abstraction with example?
i am getting an of the type can not convert int to int *. to overcome this problem what we should do?
Can you inherit a private class?
Write a java applet that computes and displays the squares of values between 25 and 1 inclusive and displays them in a TextArea box
What is the renewal class?
What is the important feature of inheritance?
What is class encapsulation?
Who invented oop?
officer say me - i am offered to a smoking , then what can you say
What is the importance of oop?
What is overloading in oops?
What is stream in oop?