#include < iostream >
#include using namespace std; class abstract phone
{
public:
virtual void dial(string number) = 0; 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;}
abstract_phone(string number) {abstract_phone::number=number;};
protected: string number;
};
class phone:public abstract_phone
{
public:
virtual void dial(string number) {cout « "Raqam to‘plami" « number « endl;}
phone(string number): abstract_phone(number) {};
};
class touch tone: public abstract_phone
{
public:
void dial(string number) {cout « "Pik Pik Raqam to‘plami" « number « endl;}
touch_tone(string number): abstract_phone(number) {}
};
class pay_phone: public abstract_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): abstract_phone(number) {pay_phone::amount = amount;}
private: int amount;
};
void dial_phone(abstract_phone& this_phone, string this number)
{this_phone.dial(this_number);}; int main()
{
Do'stlaringiz bilan baham: |