Give back multiple inheritance

Kyle Furlong kylefurlong at gmail.com
Fri Mar 24 13:04:36 PST 2006


Sean Kelly wrote:
> Johan Granberg wrote:
>> sgrantham at sympatico.ca wrote:
>>> one of the more powerful and useful expression
>>> capabilities of C++ is in multiple inheritance and its loss is to 
>>> much of a
>>> price.
>>
>> I to want multiple inheritance but I got the feeling that walter prety 
>> much have ruled that out.
> 
> For what it's worth, mixins are a capable replacement for MI in many 
> instances.
> 
> 
> Sean

To bash out a quick and dirty mixin implementation:

interface Tree
{
	void Add(Tree item);
}

template TreeFunctionality
{
	Tree Parent;
	void Add(Tree Item)
	{
		Item.Parent = this;
		LL.Add(Item);
	}
	// Implement LL
}

class tFile : File, Tree // Is the the correct syntax?
{
	mixin TreeFunctionality;
}

Some other more experienced design people can help make this better I'm sure. But it gives you the idea.



More information about the Digitalmars-d mailing list