Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

INSTANCE FIELDS DECLARED private ARE ACCESSIBLE BY THE METHODS ONLY.CAN WE CHANGE THE private FIELD OF AN OBJECT IN A METHOD OF SOME OTHER OBJECT OF THE SAME CLASS?

2203


What is constructor overloading in oop?

1133


Why do we use inheritance?

1112


Hi friends I have experience of 6 months in website design and maintanence. Now i am looking for other IT jobs.. to switch platform. please post any interview you know in chennai.

2191


Is enum a class?

1055


What is oops and its features?

1076


What is class and example?

1177


c++ program to swap the objects of two different classes

2413


What is polymorphism what is it for and how is it used?

1013


What is destructor give example?

1049


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

1850


Who invented oop?

1125


Why do pointers exist?

1085


What is the purpose of enum?

1007


Why is object oriented programming so hard?

1076