-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut24.cpp
More file actions
41 lines (33 loc) · 751 Bytes
/
Copy pathtut24.cpp
File metadata and controls
41 lines (33 loc) · 751 Bytes
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
// static variable
// static variable is written in out of class
// we can not pass count of employe from one object to another object
#include <iostream>
using namespace std;
class employee
{
int id;
static int count;
public:
void setdata(void)
{
cout << "Enter the id of the employee " << endl;
cin >> id;
count++;
}
void getdata(void)
{
cout << "The id of the emplyee is " << id << " and the number of employee is " << count << endl;
}
};
int employee ::count; // default value is zero
int main()
{
employee yash, pratham, rash;
yash.setdata();
yash.getdata();
pratham.setdata();
pratham.getdata();
rash.setdata();
rash.getdata();
return 0;
}