struct template help
Danyal Zia via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jul 12 12:16:50 PDT 2014
On Saturday, 12 July 2014 at 19:09:44 UTC, seany wrote:
> Please consider the following
>
> struct arc(T,U)
> {
>
> T some_var;
> U someother_var;
> }
>
> /* things */
>
> class myclass
> {
> this(){}
> ~this(){}
> void MYfunction()
>
> {
> arc!(string, string[]) * a;
> a.some_var = "hello";
> }
> }
>
>
> void main()
> {
> c = new myclass();
> c.MYfunction();
> }
>
>
> This leads to a segmentation fault.
>
> What am I doing wrong?
"a" has not been instantiated. You are declaring it as a pointer
to struct and using its fields without initializing it.
"arc!(string, string[]) a;" will work.
More information about the Digitalmars-d-learn
mailing list