D newb

BCS ao at pathlink.com
Sun Aug 17 16:22:27 PDT 2008


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();)





More information about the Digitalmars-d mailing list