在此页面上的示例中:http ://www.scala-lang.org/node/125
class Point(xc: Int, yc: Int) {
val x: Int = xc
val y: Int = yc
def move(dx: Int, dy: Int): Point =
new Point(x + dx, y + dy)
}
class ColorPoint(u: Int, v: Int, c: String) extends Point(u, v) {
val color: String = c
def compareWith(pt: ColorPoint): Boolean =
(pt.x == x) && (pt.y == y) && (pt.color == color)
override def move(dx: Int, dy: Int): ColorPoint =
new ColorPoint(x + dy, y + dy, color)
}
扩展类上的参数/参数列表在子类的定义中起到什么作用?我指的是行(u, v)
尾的。Point
class ColorPoint(u: Int, v: Int, c: String) extends Point(u, v) {