Click here to Skip to main content
15,922,650 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
we cannot assign child class referene to a parent class object;
Child chObj = new Parent()--this statement will give an error ,
but then how can we access properties of parent class using child ref
Child chObj1 = new Child();
chObj1.Paerntproperty1 = 1;---then why this statment is correct?
Posted
Comments
BobJanova 16-Mar-12 5:56am    
Seems like you need to go back over this section of your course and read it slower and more in depth so it goes in.

1 solution

Child obviously inherits from Parent, thus giving it all the its properties.

http://msdn.microsoft.com/en-us/library/ms173149(v=vs.80).aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900