COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
dynamic.cpp
Go to the documentation of this file.
1
2#include <iostream>
3using namespace std;
4int main()
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}
int main()
Definition dynamic.cpp:4