I made a function in dervied ninjA class void h() ..why i can access it my (*e1).h();...*e1 is point er of base class | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I made a function in dervied ninjA class void h() ..why i can access it my (*e1).h();...*e1 is point er of base class

11th Oct 2020, 8:24 PM
Harsh Rajput
Harsh Rajput - avatar
3 Answers
12th Oct 2020, 4:57 AM
Harsh Rajput
Harsh Rajput - avatar
+ 2
If the base class doesn't know about a function, you shouldn't be able to access it from a base class pointer either, unless for example you perform a cast on the pointer. Perhaps you can post a code sample demonstrating your question for clarification?
11th Oct 2020, 9:07 PM
Shadow
Shadow - avatar
+ 2
"Error: 'class Enemy' has no member named 'h', meaning you can't access the method from the base pointer as I said, so what is your question?
13th Oct 2020, 11:09 AM
Shadow
Shadow - avatar