Created
May 11, 2018 13:35
-
-
Save AqsaFiqhi/2c9e05100618428bdf212fa613807587 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class KirimPesan | |
{ | |
protected: | |
string teks; | |
public: | |
KirimPesan(string teks) | |
{ | |
this->teks = teks; | |
} | |
virtual string pesan() = 0; | |
}; | |
class Sms : public KirimPesan | |
{ | |
private: | |
string nohp; | |
public: | |
Sms(string nohp, string teks):KirimPesan(teks) | |
{ | |
this->nohp = nohp; | |
this->teks = teks; | |
} | |
string pesan() | |
{ | |
cout<<"Nomor Tujuan : "<<nohp<<endl; | |
cout<<"Pesan : "<<teks<<endl; | |
return string(); | |
} | |
}; | |
class Wa : public KirimPesan | |
{ | |
private: | |
string kontak; | |
public: | |
Wa(string kontak, string teks):KirimPesan(teks) | |
{ | |
this->kontak = kontak; | |
this->teks = teks; | |
} | |
string pesan() | |
{ | |
cout<<"Kontak Tujuan : "<<kontak<<endl; | |
cout<<"Pesan : "<<teks<<endl; | |
return string(); | |
} | |
}; | |
class Email : public KirimPesan | |
{ | |
private: | |
string email; | |
string subjek; | |
public: | |
Email(string email, string subjek, string teks):KirimPesan(teks) | |
{ | |
this->email = email; | |
this->subjek = subjek; | |
this->teks = teks; | |
} | |
string pesan() | |
{ | |
cout<<"Email Tujuan : "<<email<<endl; | |
cout<<"Subject : "<<subjek<<endl; | |
cout<<"Pesan : "<<teks<<endl; | |
return string(); | |
} | |
}; | |
int main() | |
{ | |
KirimPesan *pesan = new Sms("082188996054", "Hallo"); | |
cout<<pesan->pesan()<<endl; | |
delete pesan; | |
pesan = new Wa("Ivy", "Hai....!"); | |
cout<<pesan->pesan()<<endl; | |
delete pesan; | |
pesan = new Email("[email protected]", "Salam Kenal", "Hallo Ivy.....!"); | |
cout<<pesan->pesan()<<endl; | |
delete pesan; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment