Helo guys,
can anyone clarify me like what is the need for doing downcast and upcast ?
Thanks in advance
Printable View
Helo guys,
can anyone clarify me like what is the need for doing downcast and upcast ?
Thanks in advance
You should never need to explicitly upcast. The assignment should just work. (Be careful of slicing, though.)
Normally you should avoid downcasting, but on some occasions it's useful if you know the specific type of a particular object through other means and you need to access functionality particular to that type.