-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1pointer.cpp
More file actions
62 lines (47 loc) · 1.22 KB
/
1pointer.cpp
File metadata and controls
62 lines (47 loc) · 1.22 KB
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
// Pointer Basics- Address of Operation's-Dereference operator-Reference Variable - Pass By Reference(Reference Variables)- Pass By Reference(Pointers)
#include <iostream>
using namespace std;
/*// Pass By Reference Using Reference Variables
void applyTax(int &money){
float tax = 0.10;
money =money - money*tax;
}*/
// Pass By Reference - Pointers
void watchVideo(int *viewsPtr)
{
// watch video should increment view count by 1
*viewsPtr = *viewsPtr + 1;
}
int main()
{
/* int x = 10;
// float y = 5.34;
// cout<<&x<<endl;
// cout<<&y<<endl;
// Demo Pointer
int *xptr = &x;
cout << xptr << endl;
// Address of a Pointer Variable
cout << &xptr << endl;
// Pointer to a Pointer Variable
int **xxptr = &xptr;
cout << xxptr << endl;
// Dereference Operator
cout << *xptr << endl;
// Reference Variable :
int &y = x;
y++;
// x++;
cout << x << endl;
cout << y << endl;
// Pass By Reference - Reference Variable
int income;
cin>>income;
applyTax(income);
cout<< income <<endl; */
// Pass By Reference - Pointers
int views = 100;
watchVideo(&views);
cout << views << endl;
return 0;
}