-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstaticVar.cpp
More file actions
46 lines (41 loc) · 805 Bytes
/
Copy pathstaticVar.cpp
File metadata and controls
46 lines (41 loc) · 805 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
44
45
46
#include<iostream>
using namespace std;
void setValue()
{
int a = 2;
static int b = 3;
a++;
b++;
printf("%d ", a);
printf("%d\n", b);
}
class Account
{
private:
int balance;
public:
static float rateofinterest; // Static member Variable or class Variable
public:
void setData(int a)
{
balance = a;
cout<<balance;
}
static void setr(float b) // Static Member Function
{
rateofinterest = b;
cout<<"\n"<<rateofinterest;
}
};
float Account::rateofinterest = 0;
int main()
{
cout<<Account::rateofinterest<<"\n";
Account a;
a.setData(5000);
a.setr(10);
Account::setr(50);
// setValue();
// setValue();
return 0;
}