Unformatted text preview: on with an int as
its left operand and a TimeType as its right
operand. C++ provides an alternate method of providing
operator We need
const TimeType operator+(const TimeType&);
const TimeType iin the int class – but with access to the internals
int class but
Applied Programming W e can place this function with(in) the class
TimeType but not as a member function.
W e call it a friend of the class.
friend const TimeType operator+(int,const TimeType&);
const TimeType where the two operands are explicitly listed as
But it still needs access to TimeType.
Applied Programming W hen we write the implementation of a friend, we
do not put the keyword in front of it.
Nor do we place the class:: before it.
class:: The prototype must be preceded with the
As this is neither a public...
View Full Document
- Spring '14
- Object-Oriented Programming, Subroutine, Programming constructs, TimeType