Operator Overloading in an Abstract Base Class
"Nordlöw" via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Nov 21 00:14:41 PST 2014
On Thursday, 20 November 2014 at 22:35:51 UTC, IgorStepanov wrote:
> class Patt
> {
> // It is better then your static if.
> // Compiler will raise better error message for incorrect
> operator.
> Seq opBinary(string op)(Patt rhs) if (op == "~")
> {
> return opCatImpl(rhs);
> }
>
> protected Seq opCatImpl(Patt rhs) //you may override it in
> derived class
> {
> return seq(this, rhs);
> }
> }
Great! I've update my code! Thanks!
More information about the Digitalmars-d-learn
mailing list