COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
dynamic.cpp File Reference
#include <iostream>
Include dependency graph for dynamic.cpp:

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( void )

Definition at line 4 of file dynamic.cpp.

5{
6 int *p1, *p2;
7 p1 = new int;
8 *p1 = 42;
9 p2 = p1;
10
11 cout << "*p1 = " << *p1 << ", ";
12 cout << "*p2 = " << *p2 << endl;
13
14 *p2 = 53;
15 cout << "*p1 = " << *p1 << ", ";
16 cout << "*p2 = " << *p2 << endl;
17
18 p1 = new int;
19 *p1 = 88;
20 cout << "*p1 = " << *p1 << ", ";
21 cout << "*p2 = " << *p2 << endl;
22
23 delete p1;
24 delete p2;
25
26 return 0;
27}