Typecast issue in inheritance . . . . . . . . . . . . . . . . . . . . .

my doubt in inheritance can we typecast d2 so we shall access d2 at run time in case of reference of c and instance of p

@Nitin-Mishra-2380486738834604,

If a parent reference variable is holding the reference of the child class and we have the same data member in both the parent and child class.

Then it will refer to the parent class data member , it doesn’t matter if it is holding child class object reference or not.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.