Here is something that looks like the classes I'm currently working with.
public class SomeClass
{
public PropertyAClass A { get; set;}
public PropertyBClass B { get; set;}
public SomeClass (PropertyAClass A, PropertyBClass B)
{
this.A = A;
this.B = B;
}
public static SomeClass operator +(SomeClass a, SomeClass b)
{
return new SomeClass(a.A + b.A, a.b + b.B);
}
}
public class DerivedClass : SomeClass
{
public DerivedClass (PropertyADerivedClass A, PropertyBDerivedClass B) : base(A,B)
{
}
//Operation is the same but I have to repeat the method
public static DerivedClass operator +(DerivedClass a, DerivedClass b)
{
return new DerivedClass(a.A + b.A, a.b + b.B);
}
}
Is there some smart way that would make it possible not to repeat operator + in derived class by applying it to the base class and still getting the derived class as output ?