revision on c++ pointers tcp1201: 2013/2014. pointer basics why pointer is important? 1....

Click here to load reader

Upload: melinda-wells

Post on 18-Jan-2018

217 views

Category:

Documents


0 download

DESCRIPTION

3 int a = 3; int *p = &a; cout

TRANSCRIPT

Revision on C++ Pointers TCP1201: 2013/2014 Pointer Basics Why pointer is important? 1. Reference/Point to existing data without cloning the data. 2. Dynamic memory allocation (create the amount of data based on runtime need). 3. Dynamic polymorphism (Lecture 4) A pointer always stores the address of a data. Before we can use a pointer, it must point to a valid address that is achieved through: Pointing it to an existing data, or Using it to create a new data (use new operator). 3 int a = 3; int *p = &a; cout