There is a class Tree , it has a Mass property.
class Tree { public decimal Mass {get; set;} } There is an Apple class inherited from Tree
class Apple : Tree { } Adding to the class Tree an operator overload +
public static Tree operator +(Tree tree1, Tree tree2) { Tree result = new Tree(); result.Mass = tree1.Mass + tree2.Mass; return result; } What type of object will apple3 in the following snippet?
Apple apple1 = new Apple {Mass = 20}; Apple apple2 = new Apple {Mass = 30}; var apple3 = apple1 + apple2; I assume that the type is Tree . And how to make the implementation of the overload remain in the Tree , and as a result get Apple ? The goal is not to write an implementation for each successor Tree .
operator+exclusively over theTreefields, i.e. it is not clear what kind of implementation in the heirs can be speech. - αλεχολυτMasspublic property will be available to the heirs 2) but there is no point in talking about the implementation in the heirs because question about implementation in ancestor - 4per