MyClass , from a compiler point of view, is a way to omit the callvirt statement in favor of the call statement. In fact, when you call a method with virtual semantics ( callvirt ), you indicate that you want to use the most derived variations. In cases where you want to omit derived variations, you use MyClass ( call ). Although you stated that you understood the basic concept, I thought that this could help describe it from a functional point of view, rather than imply understanding. It is functionally identical to MyBase if the scope clause is the base type of MyBase instead of the active type with MyClass .
Overriding the semantics of virtual calls at the current point in the hierarchy is usually a poor design choice, the only times when this is true is when you have to rely on certain functionality in your object hierarchy and cannot rely on the heir to invoke your variant with using a basic call in their implementation. He can also rely on you as a designer, who decided that this is the only alternative, since you have redefined functionality in the hierarchy of objects, and you must make sure that in this corner case this particular method should be called at the current level of the inheritance tree.
All about design, understanding the overall design and corner cases. This is probably the reason why Cโฏ does not include such functionality, since in these corner cases you can divide the method into a private variable, the current current level in the hierarchy calls, and just refer to this private implementation when necessary. It is my personal opinion that using the segmentation approach is an ideal tool to achieve the goal, as it clearly concerns your design choice and is easier to track (and it is also the only valid tool in languages โโwithout the functional equivalent of MyClass .)
Alexander Morou
source share