Base (super) class in Swift
Forums:
class Shape {
var lineCount: Int
init(lineCount: Int) {
self.lineCount = lineCount
}
}
class Square: Shape {
var sideLength: Int
init (sideLength: Int) {
self.sideLength = sideLength
super.init(lineCount: 4)
}
}
let square = Square(sideLength: 5)
//square.lineCount is 4
- Log in to post comments