-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccess modifier_oops.cpp
More file actions
63 lines (33 loc) · 920 Bytes
/
Access modifier_oops.cpp
File metadata and controls
63 lines (33 loc) · 920 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include<iostream>
using namespace std;
//--------------------------------------ACCESS MODIFIER-----------------------------------------
class Coin{
public:
string c_name;
int amount;
int price;
Coin(string c_name,int amount,int price,int targit){
this->c_name = c_name;
this->amount = amount;
this->price = price;
this->targit = targit;
}
void print(){
cout<<c_name<<" "<<amount<<" "<<price<<" "<<targit<<endl;
}
private:
int targit;
// function for printing values.
};
int main(){
Coin c1("xrp",44,3,10);
// c1.targit = 90; // we can't access targit b/c its private.
// Access to private member by using constructore.
c1.print();
return 0;
}
/*
inside the class private variable is accessible for
thir method and constructore so we can access by using
class method r functions.
*/