P
P
PlaBetaVer2021-07-31 14:43:44
C++ / C#
PlaBetaVer, 2021-07-31 14:43:44

When are Upcast and Downcast used?

If I'm right that Upcast and Downcast are needed to convert a class to another class (or class objects) as is done with types (eg int num = (int)double;), then I'm probably right.

And when to use them? I don’t even understand how to apply them in practice, since nothing from the use of upcasts and downcasts comes to mind. If I rarely use type conversion, then class object conversion is unlikely to ever be used again. Then why is it such a "very important topic"?
In addition to obtaining a reference to an object, there is no more use, like.

How can I understand where upcasts and downcasts can be useful, even if in practice it is not clear how to apply them, and how to come up with a task for practice?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question