?? 9_76.cpp
字號:
#include<iostream.h>
#include<string.h>
#define Max 20
class Destination
{
protected:
char from[Max];
char to[Max];
public:
Destination()
{
strcpy(from,"");strcpy(to,"");
}
Destination(char f[],char t[])
{
strcpy(from,f);strcpy(to,t);
}
void getdata()
{
cout<<"輸入發(fā)話地點 收話地點:";
cin>>from>>to;
}
void disp()
{
cout<<"計費從"<<from<<"到"<<to;
}
};
class Time
{
protected:
int hour,minute,second;
double time;
public:
Time(){time=0;}
Time(double t){time=t;}
void getdata()
{
cout<<"輸入通話時間:時 分 秒";
cin>>hour>>minute>>second;
time=(double)(hour*3600+minute*60+second);
}
void disp()
{
cout<<"通話時間是"<<time<<"秒";
}
};
class Price:public Destination,public Time
{
double price;
public:
Price():Destination(),Time()
{price=0;}
Price(char f[],char t[],double tt):Destination(f,t),Time(tt)
{
price=(int)((tt+5)/6)*0.06;
}
void getdata()
{
Destination::getdata();
Time::getdata();
price=(int)((time+5)/6)*0.06;
}
void disp()
{
cout<<" ";
Destination::disp();
Time::disp();
cout<<",話費是"<<price<<"元"<<endl;
}
};
void main()
{
Price A;
A.getdata();
Price B("AAA","BBB",123);
cout<<"輸出結(jié)果:"<<endl;
A.disp();
B.disp();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -