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 would you overload an operator when you can just create a member method?
A1: It is easier to use overloaded operators when their behavior is well understood. It enables your class to mimic the functionality of the built-in types.
Q2:What is the difference between the copy constructor and the assignment operator?
A2: The copy constructor creates a new object with the same values as an existing object. The assignment operator changes an existing object so that it has the same values as another object.
Q3:What happens to the int used in the postfix operators?
A3: Nothing. That int is never used except as a flag to overload the postfix and prefix operators.

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