|
List Info
Thread: C-Sharp (C#) Group: Re: Inheritance
|
|
| C-Sharp (C#) Group: Re: Inheritance |

|
2006-05-08 19:54:34 |
|
That's because S is created as a Shape object, not a triangle. To have the new Triangle property available, you must cast S to a Triangle.
Do either:
Triangle S = new Triangle();
Or
Shape S = new Triangle();
Triangle T = (Triangle)S;
On 5/8/06, Sekhar <gmail.com">pcsekhar1981 gmail.com> wrote:
Hi All
I have a question on Inheritance
I have an abstract class Shape with two properties int X and int Y
I have a concrete class Triangle which inherits Shape
Triangle class has an additional property Y
abstract class Shape
{
public int x,
public int y
}
class triangle : Shape
{
public int y;
}
When i say Shape S = new Triangle();
I expect to see the properties X,Y and Z......But i only see X and Y....
I am confused
Please explain..
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C-Sharp (C#)" group. To post to this group, send email to C_Sharp googlegroups.com To unsubscribe from this group, send email to C_Sharp-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/C_Sharp -~----------~----~----~----~------~----~------~--~---
|
[1]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|