1 2 3 4 5 6 7 8 9 10 11 12

To overload(define in a special way) a binary operator, use:

DataType operator OperatorSymbol
( LeftParamType_and_Name, RightParamType_and_Name )
{// code defining the operation }

void BasicStr :: operator = (BasicStr& left, BasicStr right)
{// code defining = for use with BasicStr }

To overload the output operator, use the pattern:

ostream& operator <<
( ostream& StreamName, RightParamType_and_Name )
{// code defining the operation
return StreamName;
}

ostream& operator << (ostream& s, BasicStr& right)
{// whatever you want
return s;
}

24-Mar-98

Page 7

TAM/C201