Templated interface

Simen Kjaeraas simen.kjaras at gmail.com
Tue Oct 14 14:45:39 PDT 2008


On Tue, 14 Oct 2008 23:41:57 +0200, DF <deefriend at yahoo.com> wrote:

> Is it possible to create templated interfaces in D? And if possible than  
> can anyone provide some good example on templated interface.

interface foo(T)
{
	T property();
	T property(T value);
}

class bar : foo!(int)
{
	int data;
	
	int property()
	{
		return data;
	}
	
	int property(int value)
	{
		return data = value;
	}
}

void main()
{
	bar b = new bar;
	
	b.property = 4;
	
	writefln(b.property);
}

-- 
Simen



More information about the Digitalmars-d mailing list