-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncapsulation.cpp
More file actions
49 lines (41 loc) · 795 Bytes
/
Copy pathEncapsulation.cpp
File metadata and controls
49 lines (41 loc) · 795 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
47
48
49
#include <bits/stdc++.h>
using namespace std;
// Example with Encapsulations:
// Data Hiding
// Encapsulations in wrapping up of data/properties & members/ methods in a single class
class Account
{
private:
double balance;
string password;
public:
string account_id;
string user_name;
// setter
void setbalance(double b)
{
balance = b;
}
void setpassword(string p)
{
password = p;
}
// getter
double getbalance()
{
return balance;
}
string getpassword()
{
return password;
}
};
int main()
{
Account s1;
// using setter method set data
s1.setbalance(25000.00);
s1.setpassword("lock123");
s1.user_name = "Prolay Ghosh";
cout << s1.getbalance() << " " << s1.user_name << endl;
}