Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class contact{
- private:
- string phone;
- public:
- contact(string p){
- phone=p;
- }
- string getphone(){
- return phone;
- }
- };
- class car{
- private:
- string plate;
- public:
- car(string p){
- plate=p;
- }
- string getplate(){
- return plate;
- }
- };
- class custemer{
- private:
- string name;
- contact cont;
- car *ca;
- public:
- custemer( string na, string ph):cont(ph){
- name= na;
- }
- string getname(){
- return name;
- }
- string getphonenumber(){
- return cont.getphone();
- }
- string getrentedcarplate(){
- return ca->getplate();
- }
- void setrentedcar(car*c){
- ca=c;
- }
- };
- int main()
- {
- custemer obj[3]= { custemer ("Ahmad Kamal", "015-75769800"), custemer ("Omar Abdullah","014-8889900"), custemer("Hassan Ali", ("012-1234567"))};
- car *ca= new car("JSQ245");
- car *ca1= new car("NIL");
- car *ca2= new car("ABC890");
- obj[0].setrentedcar(ca);
- obj[1].setrentedcar(ca1);
- obj[2].setrentedcar(ca2);
- cout<<"custemer name: "<<obj[0].getname()<<endl;
- cout<<"phone number: "<< obj[0].getphonenumber()<<endl;
- cout<<"rented car: "<< obj[0].getrentedcarplate()<<endl;
- cout<< endl;
- cout<<"custemer name: "<<obj[1].getname()<<endl;
- cout<<"phone number: "<< obj[1].getphonenumber()<<endl;
- cout<<"rented car: "<< obj[1].getrentedcarplate()<<endl;
- cout<<endl;
- cout<<"custemer name: "<<obj[2].getname()<<endl;
- cout<<"phone number: "<< obj[2].getphonenumber()<<endl;
- cout<<"rented car: "<< obj[2].getrentedcarplate()<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement