Operatorb thus for our own adts to use these

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: uilt-iins) is encountered in the code of a ns) of C++ program, the compiler generates a call to a function named operator• with one argument – operator with the right operand – while the left operand is the the while class instance. class So a + b would become Similarly a == b becomes a.operator==(b) Thus, for our own ADTs to use these operators, Thus, ADTs to we provide the requisite functions. So, all we have to do for TimeType is replace TimeType bool TimeType::Equals(const TimeType& t) const by a.operator+(b) bool TimeType::operator==(const TimeType& t) const ==(const TimeType t) Applied Programming Similarly bool TimeType::operator<(const TimeType& r_op) const <(const TimeType r_op { return (hours < r_op.hours return r_op.hours || (hours == r_op.hours || r_op.hours && minutes < r_op.minutes) && r_op.minutes || (hours == r_op.hours || r_op.hours && minutes == r_op.minutes && r_op.minutes Applied Programming W e can also provide +...
View Full Document

This document was uploaded on 04/07/2014.

Ask a homework question - tutors are online