Hi Everyone,
Please let me know the solution of below question :
Q.1) How type casting is done between base class and derived class?
button_click(object sender, EventArrgs e)
Button b = (button) sender;// button class is derived from object class, for this typecasting to happen button reference must be there in object class but object class is created by microsoft so we can't see . So my question is how reference of button class is written in object class?
class Object
{
Button b;
}
class Button : Object
{}
Now can we write :
Button b = new Object();
and
Object o = new Button();
Thanks and Regards
Loading
VulpesPosted Oct 23, 2012, 4:35 PM
Rushal AroraPosted Oct 23, 2012, 3:47 PM
class Object
{
Button b;
}
class Button : Object
{}
Now can we write :
Button b = new Object();
and
Object o = new Button();
Thanks and Regards
VulpesPosted Oct 23, 2012, 10:48 AM
An object is a bit like an onion - the inner layer(s) contain the members inherited from its base class(es) and the outer layers contain the members which it adds itself.
Note however that constructors and destructors are not inherited. Technically, private members are inherited but are not accessible within a derived class.
Rushal AroraPosted Oct 23, 2012, 10:33 AM
Mahesh ChandPosted Oct 22, 2012, 7:38 PM