Why up casting cause error here?? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
10th Apr 2017, 9:34 PM
Simranjeet Singh
Simranjeet Singh - avatar
3 ответов
11th Apr 2017, 1:53 PM
Amarpreet
+ 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.
10th Apr 2017, 10:50 PM
Rrestoring faith
Rrestoring faith - avatar
- 1
This is nt up casting
10th Apr 2017, 9:37 PM
Simranjeet Singh
Simranjeet Singh - avatar