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
Can main method override?
Explain virtual inheritance?
Can destructor be overloaded?
Which type does string inherit from?
what is graphics
Why can't we have instance(stack) of a class as a member of the same class like eg.Class A{A obj;} as we can have self refential pointer
Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.
what are the realtime excercises in C++?
What is overloading and its types?
Why is static class not inherited?
i=20;k=0;
for(j=1;k-i;k+=j<10?4:3)
{
cout< what are the ways in which a constructors can be called? What is object in oops? Templates mean What does I oop mean?