Tuesday, January 6, 2009

Define overloading of operators

The operator "+" can be used to add two numbers of the same type, or to append two pieces of text, or to join a piece of text with a number.

The suggestion is that operator overloading should be strictly defined as to the arguments they can handle. Too many times, GeoMedia complains that you cannot add a short to a long integer or a real to an integer. A possibility is to create the definition so that reals added to integers return reals, and short integers added to long integers return long integers, and then use the destination of the result to determine if the operation makes sense. This will reduce hair-pulling frustration when it is not possible to determine why GeoMedia does not like an operation between what looks like 2 valid data types.

The plus operator "+" should also be used to add vectors together.

No comments: