|
|
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;
}
|
|
|
|