Click here to load reader

Revision on C++ Pointers TCP1201: 2013/2014. Pointer Basics Why pointer is important? 1. Reference/Point to existing data without cloning the data

Embed Size (px)

DESCRIPTION

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

Citation preview

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