0
Why up casting cause error here??
3 Respuestas
0
the best example
https://code.sololearn.com/cge5K9ARPXlp/?ref=app
+ 7
1) This is not casting, this is inheritance/polymorphism.
Anywho, the actual error is because you have 2 objects named "obj2".
change: a obj2 = new b(); to: a obj3 = new b();
There was also no reason to create the first 2 objects, they don't do anything.
- 1
This is nt up casting