#include
#include
using namespace std;
class SIM
{
private:
string number; //存储手机号码
public:
SIM(){}
SIM(string number) //初始化
{
this->number = number;
}
string getNumber() //读取号码
{
return number;
}
};
class Mobile
{
private:
SIM s1;
public:
Mobile(){}
Mobile(SIM s1) //初始化SIM
{
this->s1 = s1;
}
void changeSIM(SIM s2) //更改SIM卡
{
this->s1 = s2;
}
void print() //显示手机号码
{
cout << s1.getNumber() << endl;
}
};
int main()
{
SIM s1("130*******"), s2("133*******"); //定义两张SIM卡
Mobile m(s1); //在手机里放卡s1
m.print(); //输出s1卡的手机号
m.changeSIM(s2); //切换卡s2
m.print(); //输出s2卡手机号
system("pause");
return 0;
}
