I was thinking about how to solve the problem that I have, and I'm not sure if this will work or not.
Say we have a base class of subclass A and 3 of subclass B, C, and D.
A ^ ----------------- | | | BCD
We also have three classes X, Y and Z.
In my system objects, type B, C, D is passed as type A, and usually I have to convert objects of type B, C, D to objects X, Y or Z (this is not casting, I manually convert them, because they are completely different).
Therefore, in order to convert the type of object A to type X, Y or ZI, you must first check the subtype, and then initialize the object X, Y or Z with the result of some operations on object A, depending on the subtype.
I thought about overloading the explicit operation from A to X, Y or Z, just doing the same process that I did when I converted them, but then I thought ... Is it possible to use polymorphism and overload casting from B, C and D in some way, that when I add a new AI subtype, I donβt need to change the cast code A? (just add explicit cast overload to the new subtype)
Hope I correctly explained that there is something confusing.
NOTE. I will add overload for X, Y, Z