O'Reilly logo

Sams Teach Yourself C++ in 24 Hours, Third Edition by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Q&A

Q1:Why have pointers if references are easier?
A1: References cannot be null, and they cannot be reassigned. Pointers offer greater flexibility, but are slightly more difficult to use.
Q2:Why would you ever return by value from a function?
A2: If the object being returned is local, you must return by value or you will be returning a reference to a nonexistent object.
Q3:Given the danger in returning by reference, why not always return by value?
A3: There is far greater efficiency in returning by reference. Memory is saved, and the program runs faster.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required