Q&A

Q1:Why are pointers so important?
A1: During this hour you saw how pointers are used to hold the address of objects on the heap and how they are used to pass arguments by reference. In addition, in Hour 13, “Advanced Functions,” you'll see how pointers are used in class polymorphism.
Q2:Why should I bother to declare anything on the heap?
A2: Objects on the heap persist after the return of a function. Additionally, the capability to store objects on the heap enables you to decide at runtime how many objects you need, instead of having to declare this in advance. This is explored in greater depth in Hour 10.

Get Sams Teach Yourself C++ in 24 Hours, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.