#include<string>
#include<iostream>
using namespace std;
class Mobile
{
public: string IMEI_NO;
public: string Model;
public: Mobile(string im_no,string model)
{
IMEI_NO=im_no;
Model=model;
}
public: void show()
{
cout<<"IMEI no is == "<<IMEI_NO<<endl;
cout<<"Model of your mobile is == "<<Model<<endl;
}
};
class Person
{
Mobile *mymobile;
public: string name;
public: string CNIC;
public: Person(string n , string c)
{
name=n;
CNIC=c;
}
public: void show()
{
cout<<"The name of the person is == "<<name<<endl;
cout<<"The CNIC of a particular person is == "<<CNIC<<endl;
mymobile->show();
}
public:void setmobile(Mobile * m1)
{
mymobile=m1;
}
};
int main()
{
Mobile *mob;
mob=new Mobile("12589874458580","nokia 3310");
Person myperson("Anonymous","37405-58925986-5");
myperson.setmobile(mob);
myperson.show();
getchar();
return 0;
}
#include<iostream>
using namespace std;
class Mobile
{
public: string IMEI_NO;
public: string Model;
public: Mobile(string im_no,string model)
{
IMEI_NO=im_no;
Model=model;
}
public: void show()
{
cout<<"IMEI no is == "<<IMEI_NO<<endl;
cout<<"Model of your mobile is == "<<Model<<endl;
}
};
class Person
{
Mobile *mymobile;
public: string name;
public: string CNIC;
public: Person(string n , string c)
{
name=n;
CNIC=c;
}
public: void show()
{
cout<<"The name of the person is == "<<name<<endl;
cout<<"The CNIC of a particular person is == "<<CNIC<<endl;
mymobile->show();
}
public:void setmobile(Mobile * m1)
{
mymobile=m1;
}
};
int main()
{
Mobile *mob;
mob=new Mobile("12589874458580","nokia 3310");
Person myperson("Anonymous","37405-58925986-5");
myperson.setmobile(mob);
myperson.show();
getchar();
return 0;
}
can u please tell why do we have to perform the following step
ReplyDeletepublic: Mobile(string im_no,string model)
{
IMEI_NO=im_no;
Model=model;
}
thnx its really helpfull
ReplyDelete