-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.cc
40 lines (32 loc) · 856 Bytes
/
main.cc
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
#include <string>
#include "iostream"
struct IEmployee
{
virtual ~IEmployee() = default;
virtual std::string const& GetFirstName() const = 0;
virtual std::string const& GetLastName() const = 0;
virtual std::string GetFullName() const
{
return GetFirstName() + " " + GetLastName();
}
};
class Employee : public IEmployee
{
public:
Employee(std::string const& firstName, std::string const& lastName):
firstName_(firstName), lastName_(lastName)
{}
~Employee() override = default;
std::string const& GetFirstName() const { return firstName_; }
std::string const& GetLastName() const { return lastName_; }
private:
std::string firstName_;
std::string lastName_;
};
int main()
{
IEmployee* employee = new Employee("John", "Smith");
std::cout << employee->GetFullName() << std::endl;
delete employee;
return 0;
}