D1 operator overloads have been deprecated.
Timon Gehr
timon.gehr at gmx.ch
Fri Jul 12 15:07:11 UTC 2019
On 12.07.19 15:42, 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?
>
>
> import std.stdio;
>
> class X
> {
> }
> class C : X{
> int x;
> this(int x){ this.x=x; }
> C opAddImpl(C rhs){
> return new C(x+rhs.x);
> }
> alias opBinary(string op:"+")=opAddImpl;
> }
> void main(){
> X a=new C(1),b=new C(2);
> writeln((a+b).x);
> }
>
> fails.
Please do enlighten us how you would make that work with D1 operators.
More information about the Digitalmars-d
mailing list