timetype applied programming w e can place this

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: on with an int as We operator+ function int as its left operand and a TimeType as its right TimeType as operand. operand. C++ provides an alternate method of providing C++ operator overloading. operator We need const TimeType operator+(const TimeType&); const TimeType iin the int class – but with access to the internals n int class but of TimeType!!! TimeType Applied Programming W e can place this function with(in) the class We with(in the TimeType but not as a member function. TimeType W e call it a friend of the class. We friend const TimeType operator+(int,const TimeType&); const TimeType where the two operands are explicitly listed as where arguments. arguments. But it still needs access to TimeType. But TimeType Applied Programming W hen we write the implementation of a friend, we When do not put the keyword in front of it. do Nor do we place the class:: before it. Nor class:: The prototype must be preceded with the The keyword friend. friend As this is neither a public...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online