Quote:
quote:Originally posted by Jonax
Thanks Vector - the following seems to work:
Code:
...
friend cBigApple operator -- (cBigApple tmp)
{
return cBigApple(--tmp.iWormCount, --tmp.fTotalLengthOfWorms, 0.0);
}
};
...
|
You might want to make the argument to operator-- a reference to the original object, and return a reference to the object itself. It might look like:
Code:
...
const cBigApple & operator -- (cBigApple & tmp) {
iWormCount -= 1;
fTotalLenthOfWorms -= 1;
return *this;
}
...
This will make sure that the returned object is not a new instance, but rather the same instance with which you called the operator-- with.
This should apply to the other unary operators too.
Hope this helps.
Dean Michael C. Berris
Orange and Bronze Technologies, Inc.
Mobile +639287291459