-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLecture25.cpp
More file actions
56 lines (40 loc) · 843 Bytes
/
Copy pathLecture25.cpp
File metadata and controls
56 lines (40 loc) · 843 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
#include<iostream>
using namespace std;
int main () {
//pointer to int is created, and pointing to some garbage address
//int *p = 0;
//cout << *p << endl;
/*
int i = 5;
int *q = &i;
cout << q << endl;
cout << *q << endl;
int *p = 0;
p = &i;
cout << p << endl;
cout << *p << endl;
*/
int num = 5;
int a = num;
cout << "a before " << num << endl;
a++;
cout << "a after " << num << endl;
int *p = #
cout << "before " << num << endl;
(*p)++;
cout << "after " << num << endl;
//copying a pointer
int *q = p;
cout << p <<" - " << q << endl;
cout << *p <<" - " << *q << endl;
//important concept
int i = 3;
int *t = &i;
//cout << (*t)++ << endl;
*t = *t +1;
cout << *t << endl;
cout << " before t " << t << endl;
t = t + 1;
cout << " after t " << t << endl;
return 0;
}