-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractice3.cpp
More file actions
27 lines (19 loc) · 838 Bytes
/
practice3.cpp
File metadata and controls
27 lines (19 loc) · 838 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
#include <iostream>
using namespace std;
int main()
{
// double pointers. -> pointers, that point to "other" pointers.
int a = 10;
int *pointer_a = &a; // single pointer - stores the address of a.
int *pointer_b = &(*pointer_a); // single pointer - still stores the address of a
cout << "A value: " << *pointer_a << endl;
cout << "A address: " << pointer_a << endl;
cout << "A value: " << *pointer_b << endl;
cout << "A address: " << pointer_b << endl;
// Now,
int **pointer_c = &pointer_a;
cout << "Pointer-C value: " << *pointer_c << endl; // access address
cout << "Pointer-C value: " << **pointer_c << endl; // access value (inside Pointer-a)
cout << "Pointer-C address: " << pointer_c << endl;
// similarly there can be triple pointers, qudruple pointers.
}