Segmentation fault from using SList in a class?

Tim K. via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 6 03:25:28 PDT 2015


On Saturday, 6 June 2015 at 10:20:34 UTC, Marc Schütz wrote:

> Because `SList` is a struct, which is a value type that is 
> allocated where you declare it (here on the stack), while you 
> used a class, which is a reference type and has to be allocated 
> with `new`.
>
> You can also turn your `Stack` type into a struct, then it 
> works, too. (You just need to remove the constructor, which is 
> empty anyway.)

That makes sense. I overlooked that in SList's documentation and 
thought it was just a regular old class, too.

Best regards,
Tim


More information about the Digitalmars-d-learn mailing list