This preview shows page 1. Sign up to view the full content.
Unformatted text preview: s look at operators in general.
Many of C++'s built-in operators are
They designate the same general operation on
different See how simple this is.
That's why it isn't needed for this class. We can re-use almost all the built-iin operators for
our own ADTs.
ADTs The assignment operator is coming. This is called operator overloading.
operator Applied Programming Consider the public function Equals() for
our class TimeType.
iis true iif time1 and time2 are equal.
s true f time1 and time2
Wouldn't this be more natural? Applied Programming A warning
The concept of operator overloading is like
opening Pandora's Box.
There's no going back.
Provide one operator and users will assume
they're all available.
they're time1 == time2
Well, we can provide this.
Applied Programming So consider this step carefully. Applied Programming W hen a binary operator, say • (representing one
of the b...
View Full Document
This document was uploaded on 04/07/2014.
- Spring '14