So we must return a reference to the instance we so

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: t object, as in from hours = from.hours; hours from.hours minutes = from.minutes; minutes from.minutes seconds = from.seconds; seconds from.seconds Applied Programming TimeType& TimeType::operator= TimeType::operator (const TimeType& from) (const TimeType { // code here to copy the members of from // to this object return *this; } Because assignments have a value. So we must return a reference to the instance we So have just copied to. have So why is this function not void? So void Applied Programming TimeType& TimeType::operator= TimeType::operator (const TimeType& from) (const TimeType { // code here to copy the members of from // to this object return *this; return *this } Applied Programming TimeType& TimeType::operator= TimeType::operator (const TimeType& from) (const TimeType { // code here to copy the members of from // to this object return *this; return *this } W e are returning the dereference of this We this – which is the address of the current instance. Because assignments hav...
View Full Document

This document was uploaded on 04/07/2014.

Ask a homework question - tutors are online