Cast class reference to pointer of another class?

Imperatorn johan_forsberg_86 at hotmail.com
Fri Jun 11 08:32:08 UTC 2021


On Thursday, 10 June 2021 at 23:47:33 UTC, Paul Backus wrote:
> On Thursday, 10 June 2021 at 21:25:35 UTC, JN wrote:
>> I have to disagree. I don't see a good reason for this 
>> behavior and it's just one more thing to trip people. I think 
>> it'd be better if such thing was done explicit, something like:
>>
>> ```d
>> Bar b = new Bar();
>> Foo* f2 = cast(Foo*)b.ptr;
>> ```
>
> Isn't having to write out `cast(Foo*)` already pretty explicit?

^


More information about the Digitalmars-d-learn mailing list