Should operator overload methods be virtual?
dsimcha
dsimcha at yahoo.com
Fri Nov 27 18:00:15 PST 2009
== Quote from Walter Bright (newshound1 at digitalmars.com)'s article
> Making them not virtual would also make them not overridable, they'd all
> be implicitly final.
> Is there any compelling use case for virtual operator overloads? Keep in
> mind that any non-virtual function can still be a wrapper for another
> virtual method, so it is still possible (with a bit of extra work) for a
> class to have virtual operator overloads. It just wouldn't be the default.
What would making them non-virtual accomplish? I don't think making them
non-virtual would hurt too much in practice, but it would introduce an
inconsistency into the language relative to "regular" methods. Therefore, I don't
think it should be done without a very good reason.
More information about the Digitalmars-d
mailing list