Quantcast
Channel: SCN: Message List - ABAP Objects
Viewing all articles
Browse latest Browse all 159

Re: downcasting

$
0
0

Hi Alexander,

 

in addition to what Adam wrote below and hoping that I understood your question correctly: you need to distinguish between designtime and runtime when looking at "method of subclass or superclass is called".

 

You will at runtime always execute the method that belongs to the instance you created, so the creating of the instance defines whether it is the super- or subclass.

 

A widening cast just helps you at design time: if for whatever reason you happen to have access to a superclass (interface restrictions for example), but you know that the caller might provide you with a subclass, you can use the widening cast to gain access to the functionality of the subclass at designtime.

 

Am I making sense?

 

Best regards,

Thorsten


Viewing all articles
Browse latest Browse all 159

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>