D newb

Tim H thockin+d at hockin.org
Sun Aug 17 16:29:48 PDT 2008


BCS Wrote:

> Reply to Tim,
> 
> > Hi, I am a D newbie.  Why does this program segfault?
> > 
> > import std.stdio;
> > import std.c.stdlib;
> > class Foo
> > {
> > public int m_int = 0;
> > }
> > int
> > main(string[] args)
> > {
> > Foo f;
> > printf("foo %d\n", f.m_int);
> > return EXIT_SUCCESS;
> > }
> 
> The default value for any object Reference (f in this case) is null. create 
> a new object to use (Foo f = new F();)

Doh, can you guess what language I am coming from? :)

Is there any way to do C++ style on-stack local object ?




More information about the Digitalmars-d mailing list