-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbasic.cpp
More file actions
60 lines (54 loc) · 1.25 KB
/
Copy pathbasic.cpp
File metadata and controls
60 lines (54 loc) · 1.25 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
using namespace std;
class AbstractEmployee{
/*Abstract class with pure virtual function:
This function should be implemented in every class
that inherits it.*/
virtual void askForPromotion() = 0;
};
class Employee : AbstractEmployee{
private:
string Name;
string Company;
int Age;
public:
void setName(string name){
Name = name;
}
string getName(){
return Name;
}
void setCompany(string company){
Company = company;
}
string getCompany(){
return Company;
}
void setAge(int age){
Age = age;
}
int getAge(){
return Age;
}
void introduceYourself() {
cout << "Name- " << Name << endl;
cout << "Company- " << Company << endl;
cout << "Age- " << Age << endl;
}
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("Sam", "Liquid-Telecoms", 25);
Employee employee2 = Employee("John", "Amazon", 35);
employee2.askForPromotion();
employee1.askForPromotion();
}