1 / 10

#include < iostream > #include < cstring > u sing namespace std; class telephone { public:

#include < iostream > #include < cstring > u sing namespace std; class telephone { public: telephone(char *number, int volume); int dial(char * outgoing_number ); protected: char phone_number [32]; int volume; }; telephone::telephone(char *number, int volume) {

geona
Download Presentation

#include < iostream > #include < cstring > u sing namespace std; class telephone { public:

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. #include <iostream> #include <cstring> using namespace std; class telephone { public: telephone(char *number, int volume); int dial(char *outgoing_number); protected: char phone_number[32]; int volume; }; telephone::telephone(char *number, int volume) { strcpy(telephone::phone_number, number); telephone::volume = volume; } int telephone::dial(char *outgoing_number) { cout << “Use a rotary or touch-tone phone to call:”<< outgoing_number; cout << “Volume: ” << volume << endl; return(1); }

  2. class touch_tone: public telephone { public: touch_tone(char *number, int volume) : telephone(number, volume) { }; int dial(char *outgoing_number); }; int touch_tone::dial(char *outgoing_number) { cout << “Beep beep beep with touch tone:” << outgoing_number; cout << “ Volume:” << volume << endl; return(1); }

  3. class rotary: public telephone { public: rotary(char *number, int volume) : telephone (number, volume) { }; int dial(char *outgoing_number); }; int rotary::dial (char *outgoing_number) { cout << “Click click click with rotary: “ << outgoing_number; cout << “ Volume: ” << volume << endl; return(1); }

  4. void main(void) { touch_tone office(“363-1111”, 5); rotary home(“555-1234”, 2); telephone *cellular = new telephone (*111-2222”, 3); home.dial(“222-3333”); office.dial(“333-4444”); cellular ->dial(“123-4567”); cellular = &office; cellular ->dial(“890-1234”); }

  5. class telephone { public: telephone(char *number, int volume); virtual int dial(char *outgoing_number); protected: char phone_number[32]; int volume; }; class rotary: public telephone { public: rotary(char *number, int volume): telephone(number, volume) { }; int dial(char *outgoing_number); }; class touch_tone: public telephone { public: touch_tone(char *number, int volume): telephone(number, volume){ }; int dial(char *outgoing_number); };

  6. #include <iostream> #include <cstring> using namespace std; class telephone { public: telephone(char *number, int volume); virtual int dial(char *outgoing_number); protected: char phone_number[32]; int volume; }; telephone::telephone(char *number, int volume) { strcpy(telephone::phone_number, number); telephone::volume = volume; } int telephone::dial(char *outgoing_number) { cout << “Use a rotary or touch_tone phone to call: ” << outgoing_number; cout << “ Volume: ” << volume << endl; }

  7. class touch_tone: public telephone { public: touch_tone(char *number, int volume) : telephone(number, volume) { }; int dial(char *outgoing_number); }; int touch_tone::dial(char *outgoing_number) { cout << “Beep beep beep with touch tone: ” << outgoing_number; cout << “ Volume: ” << volume << endl; return(1); }

  8. class rotary: public telephone { public: rotary(char *number, int volume) : telephone(number, volume) { }; int dial(char *outgoing_number); }; int rotary::dial(char *outgoing_number) { cout << “Click click click with rotary: ” << outgoing_number; cout << “ Volume: ” << volume << endl; return(1); {

  9. void main(void) { touch_tone office (“363-1111”, 5); rotary home(“555-1234”, 2); home.dial(“222-3333”); office.dial(“333-4444”); }

  10. void main(void) { touch_tone office (“363-1111”, 5); rotary home(“555-1234”, 2); telephone *cellular; home.dial(“222-3333”); office.dial(“333-4444”); cellular = &home; cellular ->dial(“555-1234”); cellular = &office; cellular ->dial(“555-5678”); }

More Related