How to do "C++ classes"?
Ferhat Kurtulmuş
aferust at gmail.com
Mon Sep 20 15:56:44 UTC 2021
On Monday, 20 September 2021 at 15:45:08 UTC, Adam D Ruppe wrote:
> On Monday, 20 September 2021 at 15:35:02 UTC, Ferhat Kurtulmuş
> wrote:
>> I thought it's stack-allocated and scoped.
>
> It is.
>
>> But when I try to return a class instance from a function, it
>> still works?
>
> dmd only makes that an error if you specify `@safe` and i think
> `-dip1000`. Try adding one or both of those and recompiling and
> see what happens.
>
> Note that even if the compiler doesn't error on it, it is
> undefined behavior to return the stack reference so be sure to
> treat it right.
That is what I thought too. I only tried this on the online
compiler. Thank you. Have a great day or night captain.
More information about the Digitalmars-d-learn
mailing list