-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3.2.cpp
44 lines (42 loc) · 1.06 KB
/
3.2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
void SendSms(const string& number, const string& message){
cout << "Send '" << message << "' to " << number << endl;
}
void SendEmail(const string& email, const string& message){
cout << "Send '" << message << "' to " << email << endl;
}
class iNotifier{
public:
virtual void Notify(const string& message) = 0;
};
class SmsNotifier{
public:
SmsNotifier(const string& num) : number(num) {}
const string number;
void Notify(const string& message) const {
SendSms(number, message);
}
};
class EmailNotifier{
public:
EmailNotifier(const string& mail) : email(mail) {}
const string email;
void Notify(const string& message) const {
SendEmail(email, message);
}
};
void Notify(iNotifier& notifier, const string& message){
notifier.Notify(message);
}
int main(){
string number = "8(800)555-35-35";
string email = "[email protected]";
SmsNotifier a(number);
EmailNotifier b(email);
a.Notify("Where is the money, Lebowski?");
b.Notify("A very important message.");
return 0;
}