Wednesday, November 21, 2007

Little Sugar : Why constantness helps

Say u have a method like this :

const Rational operator*(const Rational& lhs,
const Rational& rhs);


Now consider this (a * b ) = c

If the above method returned a non const object then the above mentioned
assignment would make sense , ideally it should not as it would be violating the
api contract for built ins.


No comments: