Discover the top 5 tips for understanding .NET Interop
Skip Navigation Links
C# Corner Home
Forum Home
Latest 50
Unanswered
Win Prizes
All Time Leaders
Jump to CategoryExpand Jump to Category
Login 
    Welcome Guest!
 Search Forum For :  
X
 Login
Please login to submit a new post, reply and edit exiting posts, see user profiles, and access more features. If you are not a registered member, Register here.
User Id / Email:
Password:  
Forgot Password | Forgot UserName
   Home » .NET General » inheritence concept
       
Author Reply
bhanu prasannakumar
posted 80 posts
since May 19, 2010 
from

inheritence concept

  Posted on: 20 Jul 2010       
in inheritence concept overridden concept is there  ,there i faced a problem i.e child class object is assigned to  the parent class reference .so we r accessing the methods with same signature in parent class and child class those only we r accessing. but we r unable acess the other memberes of child class. actually  my doubt is in memory point of view we r considered the what we r access the child class memberes by using parent class reference those r also same memory location why can't we r access the other methods of child class
for example


class A   //parent class
{
public void add()  //method
{
statments;
}

class B:A  //inheriting
{
public void add()   //assume overridden method we r access only these method only from parent class reference
{
statements;
}
public void sub()  //unable to access the method through parent class reference why?add and sub methods r stored in same memory location but we r access only add method why not sub method
{
statements;
}
}

   please help me the answer for my question.






bhanu
Jaish Mathews
posted  321 posts
since  Aug 12, 2005 
from  Bangalore, India

 Re: inheritence concept
  Posted on: 20 Jul 2010        0  

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.


Regards


Jaish Mathews

bhanu prasannakumar
posted  80 posts
since  May 19, 2010 
from 

 Re: inheritence concept
  Posted on: 05 Aug 2010        0  
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.
bhanu
Jaish Mathews
posted  321 posts
since  Aug 12, 2005 
from  Bangalore, India

 Re: inheritence concept
  Posted on: 05 Aug 2010        0  
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.


Regards


Jaish Mathews

Sam Hobbs
posted  5925 posts
since  Sep 07, 2009 
from  Los Angeles, California, USA

 Re: inheritence concept
  Posted on: 05 Aug 2010        0  

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.
       
DevExpress Free UI Controls
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Discover the Top 5 .NET Memory Management Fundamentals
To write the best .NET code, you need to know exactly how the .NET framework really manages memory. Ricky Leeks presents the Top 5 fundamental facts of .NET memory management. Learn more.
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
Team Foundation Server Hosting
 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Advertise with us
Current Version: 5.2011.3.12
 © 1999 - 2012  Mindcracker LLC. All Rights Reserved