#include
#include using namespace std; class phone {
public:
virtual void dial(string number) {cout « "Raqam to‘plami" « number « endl;}
void answer(void) {cout « "Javobni kutish" « endl;}
void hangup(void) {cout« "Qo‘ng‘iroq bajarildi-trubkani qo‘yish" « endl;}
void ring(void) {cout « "Qo‘ng‘iroq, qo‘ng‘iroq, qo‘ng‘iroq" « endl;} ‘
phone(string number) {phone::number = number;};
protected:
string number;
};
class touch tone: public phone
{
public:
void dial(string number) {cout « "Pik Pik Raqam to‘plami" « number « endl;}
touch_tone(string number): phone(number) {}
I»
class payphone: public phone
{
public:
void dial(string number) {cout « "Iltimos to‘lang" « amount « "sent" « endl;
cout « "Raqam to‘plami" « number « endl;} pay_phone(string number, int amount): phone(number) {pay_ phone::amount=amount;} private:
int amount;
};
void dial_phone(phone& this_phone, string this_number) {this_phone.dial(this_number);};
int main()
{
payphone city_phone("702-555-1212", 25); touch tone home_phone("555-1212"); phone rotary("201-555-1212");
// Obyekt diskli telefonga aylantirilsin dial_phone(rotary, "818-555-1212");
// Obyekt shakli tugmachali telefonga o‘zgartirilsin dial_phone(home_phone, "303-555-1212");
Do'stlaringiz bilan baham: |