我Ellipse
类应该从我Shape
类继承,但我收到此错误信息:重写属性不起作用
错误1“ConsoleApplication3.Ellipse”不实现继承的抽象成员“ConsoleApplication3.Shape.Perimeter .get'
我还收到了我隐藏的错误消息Area
,属于Ellipse
的属性。
任何人都可以帮助我吗?
我的形状类看起来是这样的:
public abstract class Shape
{
//Protected constructor
protected Shape(double length, double width)
{
_length = length;
_width = width;
}
private double _length;
private double _width;
public abstract double Area
{
get;
}
我的椭圆形类是:
class Ellipse : Shape
{
//Constructor
public Ellipse(double length, double width)
:base(length, width)
{
}
//Egenskaper
public override double Area
{
get
{
return Math.PI * Length * Width;
}
}
}
你能展示这两个类的代码吗? – 2011-12-26 22:36:59
我把你的示例代码粘贴到控制台应用程序中,添加了长度和宽度的访问器,它编译得很好。比较你的示例代码和你的真实代码,你应该得到你的答案。 – 2011-12-26 22:51:15