A Fresh Look at Comparisons, Take 2
Janice Caron
caron800 at googlemail.com
Fri Apr 18 06:56:03 PDT 2008
On 18/04/2008, Jason House <jason.james.house at gmail.com> wrote:
> IMHO, explicit is dangerous. It suffers from all the normal pitfalls of non-virtual function calls. Explicit helps when you have all the raw objects and have to be explicit in how you use them, but when calling functions that accept a base class or using an object factory, it gets more complex.
You wouldn't use it in that circumstance. You'd use it when you needed
it - i.e. when you desired the behavior it provides.
It neatly solves the problem of
class A
{
/* provide opCmp */
}
class B : A {}
class C : A {}
B b = new B;
C c = new C;
if (b < c) ...
doing the wrong thing.
More information about the Digitalmars-d
mailing list