C++ basic inheritance question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

C++ basic inheritance question

My input is not 0 but still why 0 is displaying always? https://code.sololearn.com/cHYaqPT2dKWe/?ref=app

25th Oct 2020, 5:03 PM
Gajendra Sonare
Gajendra Sonare - avatar
3 Answers
+ 2
Because objA and objB are 2 different objects. You store the input in objA but objB is unaffected by it because it has it's own storage. Try calling inp on objB instead.
25th Oct 2020, 5:18 PM
Dennis
Dennis - avatar
0
NotAPythonNinja Thank you so much for your help.
25th Oct 2020, 5:26 PM
Gajendra Sonare
Gajendra Sonare - avatar
0
Dennis Thank you for responding.
25th Oct 2020, 5:26 PM
Gajendra Sonare
Gajendra Sonare - avatar