Scope & Structs

Salih Dincer salihdb at hotmail.com
Sun Oct 13 05:12:32 UTC 2024


On Saturday, 12 October 2024 at 13:11:52 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> You are not wrong, when it is a struct, it is being heap 
> allocated.

Sorry for prolonging the topic. I am very curious about your 
answers along with your patience...

Can we say that structs are in the stack (LIFO) as long as we do 
not use the new operator? Also, should using scope in structures 
cause a change? I never seen it does! However, there is no 
incompatibility here: Whether it is a class or a struct, when you 
use the new operator, the first run constructor becomes the first 
run destructor with FIFO logic.

You can reverse this situation with scope (but only in classes). 
By reverse I don't mean LIFO! In fact, the correct expression is 
that when you are done with the object, it is removed.

Thanks, SDB at 79


More information about the Digitalmars-d-learn mailing list