【发布时间】:2015-05-01 03:06:07
【问题描述】:
我有两个问题。一个是Box 正在从Rectangle 继承值,但我收到错误“不包含采用 0 个参数的构造函数”。什么意思?
class Box : Rectangle
{
private double height;
private double Height
{
get { return height; }
set { if (value > 0) height = value; }
}
//Error for box: Does not contain a constructor that takes 0 arguments
public Box (double l, double w, double h)
{
length = l;
width = w;
height = h;
}
public double findArea(double h)
{
return h * h;
}
public double findVolume(double l, double w, double h)
{
return l * w * h;
}
public String toString()
{
return ("The volume is " + " cm");
}
}
另一个问题我无法从 Rectangle 类访问 protected 值,我也不确定如何处理,因为我阅读并尝试了其他网站的方法,但我不太明白。
【问题讨论】:
-
意思是:“Compiler Error CS1729”。真的不难找。您是否尝试在包含错误的错误列表行上按 F1?