-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatic.cpp
More file actions
43 lines (39 loc) · 882 Bytes
/
static.cpp
File metadata and controls
43 lines (39 loc) · 882 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
42
43
#include<iostream>
using namespace std;
class kitefestival
{
private:
int kite; //instance variable or member variable
static int charkhi; //Static variable
public:
void setkite(int k)
{
kite = k;
cout << "Number of Kites : " << k << endl;
charkhi++;
}
void display() //instance member function
{
cout << "Charkhi used : " << charkhi << endl;
}
static void see() //static member function
{
cout << "Charkhi used : " << charkhi << endl;
}
};
int kitefestival::charkhi=0; //static member variable define
int main()
{
kitefestival::see(); //without creating object calling of static member variable using static member function
kitefestival a,b,c;
a.display();
b.display();
c.display();
a.setkite(5);
a.display();
b.setkite(8);
b.display();
c.setkite(10);
c.display();
return 0;
}