-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabstraction.cpp
43 lines (35 loc) · 867 Bytes
/
abstraction.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
#include<iostream>
using namespace std;
class AbstractEmployee // abstract class
{
virtual void AskForPromotion() = 0; // obligatory - pure virtual function
};
class Employee:AbstractEmployee
{
private:
string Name;
string Company;
int Age;
public:
Employee(string name, string company, int age)
{
Name = name;
Company = company;
Age = age;
}
void AskForPromotion()
{
if(Age>=30)
cout << Name << " got promoted!" << endl;
else
cout << Name << ", sorry. No promotion for you!" << endl;
}
};
int main()
{
Employee employee1 = Employee("Rounak", "Apple", 20);
Employee employee2 = Employee("Saldina", "YT-CodeBeauty", 35);
employee1.AskForPromotion();
employee2.AskForPromotion();
return 0;
}