Replies: 1 comment 15 replies
-
I believe it's a similar reason: casting from base to derived already has a meaning in the language as a type test. It would be really confusing if such a cast sometimes behaved differently, so the language does not allow it. |
Beta Was this translation helpful? Give feedback.
15 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It is perfectly understandable why derived-to-base would be disallowed, after all it is already part of a runtime. But why would base-to-derived be disallowed too?
Also note that it is important to define such conversions in the derived type, not the base, because:
Beta Was this translation helpful? Give feedback.
All reactions