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
Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)
Why oops is important?
What are oops methods?
What is oops with example?
What is abstraction in oop with example?
Is this job good for future? can do this job post grduate student?
to find out the minimum of two integer number of two different classes using friend function
Can we create object of interface?
What is oops and why we use oops?
Is enum a class?
What is the significance of classes in oop?
design a c++ class for the chess board,provide a c++ class definition for such class(only class definition is required)
What is abstraction with example?
What do you mean by Encapsulation?
write a programe to calculate the simple intrest and compund intrest using by function overlading