Limited member function templates?
Nathan Reed
nathaniel.reed at gmail.com
Sun Nov 11 10:20:03 PST 2007
Yigal Chripun wrote:
> I may be mistaken, but isn't it enough to use the following:
> ----
> interface Collection (T) {
> void addAll(T) (Collection!(T) toAdd);
> }
> ----
> a bicycle should conform to a is-a relationship
> (a bicycle is a vehicle). so you can in fact add them all due to
> inheritance. or am I missing something here?
Unfortunately that doesn't quite work. Even if a bicycle is-a vehicle,
it doesn't follow that a collection of bicycles is-a collection of
vehicles. Consider that you can add a car to a collection of vehicles,
but it would be an error to add a car to a collection of bicycles.
Thanks,
Nathan Reed
More information about the Digitalmars-d
mailing list