Bug or Feature?

leoandru leoandru_member at pathlink.com
Wed Jun 14 08:07:20 PDT 2006


In article <3gav82l5bdkt0logigc3vokptkk35nrkvn at 4ax.com>, Max Samuha says...
>
>On Tue, 13 Jun 2006 21:56:40 +0000 (UTC), leoandru
><leoandru_member at pathlink.com> wrote:
>
>><code>
>>interface Foo
>>{
>>Object clone();
>>}
>>
>>class Bar : Foo
>>{
>>Bar clone()
>>{
>>return this; 
>>}
>>
>>}
>>
>>void main()
>>{
>>Bar b = new Bar();
>>Bar c = b.clone(); //works fine
>>
>>Foo f = b;
>>Foo g = f.clone(); //access violation
>
>Threre should be a cast to Foo: Foo g = cast(Foo)f.clone(). The code
>works well for me (WinXP, D 0.160). 
>
>>}
>></code>
>
>Do you get access violation or AssertError? If it's AssertError, you
>might forget to put 'return' in a function that requirs a value to be
>returned (int main(...){return 0;}?). D doesn't warn about missing
>returns at compile time.
>


Yeah I had a return in the affected code in that example I returned a reference
to the object itself. gessh! didn't know I had to cast ok thanks! I'll try that
then.





More information about the Digitalmars-d mailing list