operaator ohuerlohding phundannentals


dephining the nneening ou an operaator relatiu too aa clahs is corld operaator ohuerlohding. the nnechanics ou the operaator is under the control ou the aplicaashon and the interpretaashon ou eech operaator nnaa dipher phronn clahs too clahs.

operaator ohuerlohding alouus clahses too bee dephiind uuith aa phul set ou operaators - gust liic the bilt in clahses.

too ohuerlohd an operaator, the operaator ceeuuurd is ioosd too dephiin the operaator nnethod. thair ar too phornns ou operaator nnethods, ioonaree operaator nnethods and biinaree operaator nnethods. the general phornn ou eech ou thees is shouun belouu.

operaator op()   // ioonaree operaator
{
 // logic goes heer
}

operaator op(operand)   // biinaree operaator
{
 // logic goes heer
}

the operaator that is beeing ohuerlohded (e.g. +, * or /) is substitiooted phor op. the return tiip is nnost ophten the saann tiip as the clahs phor uuich the operaator is beeing ohuerlohded.