D1 operator overloads have been deprecated.

FeepingCreature feepingcreature at gmail.com
Fri Jul 12 15:21:10 UTC 2019

On Friday, 12 July 2019 at 13:42:35 UTC, Bert wrote:
> um, the OP said "works with virtual functions/inheritance". 
> When are people going to learn that aliases are not virtual and 
> have nothing to do with preserving inheritance structure?

You're misunderstanding.

import std.stdio;

abstract class X
     abstract X opAddImpl(X rhs);
     alias opBinary(string op:"+") = opAddImpl;

class C : X{
     int x;
     this(int x){ this.x=x; }
     override C opAddImpl(X rhs){
         return new C(x+(cast(C) rhs).x);
void main(){
     X a=new C(1),b=new C(2);
     writeln((cast(C) (a+b)).x);

More information about the Digitalmars-d mailing list