realbasic-nug
[Top] [All Lists]

Re: Overloaded Operators

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Overloaded Operators
From: Phil Mobley <phil at mobleybros dot com>
Date: Tue, 30 Nov 2004 11:42:51 -0800
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <BDD0D861 dot 5C5FF%mars at realsoftware dot com>
On Nov 29, 2004, at 1:45 PM, Mars Saxman wrote:

So there is no implicit Operator_Convert?

No. Operator_Convert only applies when you assign a value to a variable, pass a value as a parameter, or otherwise use a value in a context where a specific datatype is expected.

Thanks for the help so far, but I have another question...

OK, so there is no automatic conversion done by the compiler (I am fine with the reasons for this as I can easily see how it could be ambiguous).

Is there a way for me to simplify the code in each of these overloaded operators so that I can have something like this:

Function Operator_Add(x As Integer) As Rational

  Return Me + Operator_Convert(x)

End Function

Also, I am a little confused by the Operator_Negate(). Is it always called with subtraction and if yes, should I use addition in the Operator_Subtract method? An example would help clarify this for me.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>