0

Why ob2.f(7) is Error? Aren't methods inherited ???

https://code.sololearn.com/cse1ujXDybRY/?ref=app

8th Oct 2019, 5:25 AM
UraL
4 odpowiedzi
+ 2
f is overridden in class B. So you can't pass it any argument. If you call it without argument or comment out f declaration in class B, it'll work fine.
8th Oct 2019, 5:44 AM
Qasem
+ 2
It's 'coz you've overridden the method f in class B to take no arguments. Thus calling it with an argument, f(7), will obviously raise an error.
8th Oct 2019, 5:47 AM
Шащи Ранжан
Шащи Ранжан - avatar
+ 2
I thought that f () is overridden, and f (int) is inherited
8th Oct 2019, 6:33 AM
UraL
+ 1
Thanx
8th Oct 2019, 6:36 AM
UraL