-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEX08a_pointer.cpp
30 lines (29 loc) · 1.02 KB
/
EX08a_pointer.cpp
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
#include <iostream> // for using cout
using namespace std;
int main()
{
//----------------------------------------------------------------
cout << "EX08a_pointer: Pointer and references definitions" << endl;
//----------------------------------------------------------------
double x;
double* ptr_x;
double& ref_x = x; // initialisation is needed
x = 1.23456789;
ptr_x = &x;
cout << "x:\t" << x << " \t" \
<< "&x:\t" << &x << "\t" \
<< sizeof(x) \
<< endl;
cout << "ptr_x:\t" << ptr_x << "\t" \
<< "&ptr_x:\t" << &ptr_x << "\t" \
<< sizeof(ptr_x) \
<< endl;
cout << "ref_x:\t" << ref_x << " \t" \
<< "&ref_x:\t" << &ref_x << "\t"\
<< sizeof(ref_x) \
<< endl;
//----------------------------------------------------------------
cout << "Schreiben Sie die Ausgabe so um, dass die Ausdruecke mit gleichen Werten bzw. Adressen nebeneinander stehen." << endl;
//----------------------------------------------------------------
return 0;
}