Jaish Mathews
posted
321 posts
since
Aug 12, 2005
from
Bangalore, India
|
|
Re: inheritence concept
|
|
|
|
|
|
|
|
|
|
|
Hi,
Sub() can not access from parent. It's following below OOPS theory
Child classes may access parent members, but parent classes can not access child members.
In real world example, Teacher is base class and Maths teacher is sub class. Maths Teacher will get all behaviour of base class Teacher besides specialized in Maths. But it's meaningless to say base class Teacher will get all behaviour of a Maths Teacher.
|
|
|
|
|
|
bhanu prasannakumar
posted
80 posts
since
May 19, 2010
from
|
|
Re: inheritence concept
|
|
|
|
|
|
|
|
|
|
|
k,i agree with ur answer .but my doubt is we can see add and sub method are stored in same memory location but we r accessing the only add method why not sub.sub is also stored at same memory location na.
|
|
|
|
|
|
Jaish Mathews
posted
321 posts
since
Aug 12, 2005
from
Bangalore, India
|
|
Re: inheritence concept
|
|
|
|
|
|
|
|
|
|
|
How do you identify they are in same memory area? If same memory area means only one methos really exists. All other methods just Ref. to that area even though they are not really exists. Here nto that case.
|
|
|
|
|
|
Sam Hobbs
posted
5925 posts
since
Sep 07, 2009
from
Los Angeles, California, USA
|
|
Re: inheritence concept
|
|
|
|
|
|
|
|
|
|
|
Can you please fix your spelling errors and other syntax errors in your message? Please don't do things such as say "r" instead of "are". I understand that English is not your primary language and I want to do the best I can to undersand you. I am not saying you have to use perfect English; I am just asking that you try to fix errors. I think you are not trying enough to fix errors in spelling and such.
I really, really don't understand "we r considered the what we r access the child class memberes".
I thik you are saying that you want to execute the sub function from an instance of the A class and instead of explaining why that won't work, the answer is that it just won't work; you cannot do that. You can make sub a virtual function in the A class and then you probably can do what you need to do.
|
|
|
|
|
Thinking is a feeling; pleasant for some and unpleasant for others.
|
|
|
|
|
|