-
Notifications
You must be signed in to change notification settings - Fork 0
/
a1.10b.cpp
64 lines (51 loc) · 1.19 KB
/
a1.10b.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* 10...
* ...When do we use static data member and static function in a
* class? Exemplify.
*/
#include <iostream>
using namespace std;
class Employee {
public:
Employee(int s = 50000){
salary = s;
};
void increaseSalary(){
salary += salary*0.15; //increase salary of every employee by 15% and round-off
increaseCount();
};
static void printCount(){
cout << counter << endl;
};
void printSalary(){
cout << salary << endl;
};
private:
static int counter;
int salary;
static void increaseCount(){
++counter;
};
};
int Employee::counter{ 0 };
int main(){
Employee emp1(60000), emp2, emp3(80000);
emp1.increaseSalary();
cout << "Employee: ";
emp1.printCount();
cout << "Salary: ";
emp1.printSalary();
cout << endl;
emp2.increaseSalary();
cout << "Employee: ";
emp2.printCount();
cout << "Salary: ";
emp2.printSalary();
cout << endl;
emp3.increaseSalary();
cout << "Employee: ";
emp3.printCount();
cout << "Salary: ";
emp3.printSalary();
return 0;
}