Replace the Operator_Convert subroutines by constructors in your
code. Then you could certainly write
dim c as Class1 = new Class2("hello world")
and get the result that you want. Using Operator_Convert will not
work for the reasons I provided.
Charles Yeomans
On May 5, 2007, at 4:21 PM, kev wrote:
> So I guess there's no way around this that will also maintain
> polymorphism?
>
>> On 5-May-07, at 10:08 AM, Charles Yeomans wrote:
>>
>>>
>>> This is exactly what I would expect. What's happening is that the
>>> compiler sees the assignment of a String to a variable of type
>>> Class1. It then looks for an Operator_Convert subroutine with
>>> parameter of type String, which it finds. So it creates a new
>>> Class1
>>> object and calls Operator_Convert.
>>>
>>> That myClass was not nil prior to the execution of this line
>>> does not
>>> matter.
>>
>> One thing that is important is that myClass is declared to be a
>> SuperClass so the operator_convert creates a new instance of the
>> DECLARED type.
>> As Charles said, the fact it was not nil prior to this makes no
>> difference as the use of operator_convert first creates a new
>> instance and does the defined conversion.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>