Hours ropminutes ropsecondslop ropminutes

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: nor private As public nor private member function it is placed first within the class. Applied Programming And we have to reference the members of the And instance explicitly. instance Here is a suitable implementation. Applied Programming const TimeType operator+(int l_op, const TimeType const TimeType& r_op) const TimeType r_op { TimeType temp(r_op.hours, r_op.minutes, r_op.seconds+l_op); r_op.minutes r_op.seconds+l_op // code here to make values within range return temp; } W e said a few slides back that we regularly need We an assignment operator. Let's make one. an TimeType& TimeType::operator= TimeType::operator (const TimeType& from) (const TimeType { // code here to copy the members of from // to this object return *this; } Very similar to the copy constructor. 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; } The function performs the copy from the source The instance from to the curren...
View Full Document

This document was uploaded on 04/07/2014.

Ask a homework question - tutors are online