[ create a new paste ] login | about

Link: http://codepad.org/RrmwJXvw    [ raw code | output | fork ]

D, pasted on Sep 25:
import std.c.stdio;

class A
{
	~this(){
		printf("dstruct A\n");
		fflush(stdout);
	}
	void func(){}
}

class B
{
	protected A a;
	this(){a = new A;}
	void test(){a.func();}
	~this()
	{
		printf("dstruct B\n");
		fflush(stdout);
	}
}

class D : B
{
	~this()
	{
		printf("dstruct D\n");
		fflush(stdout);
		super.test();
	}
}


void main()
{
	D d = new D;
}


Output:
1
2
3
4
dstruct A
dstruct D

Segmentation fault


Create a new paste based on this one


Comments: