[Swift]required修飾子とinit()のサンプル

書式
required init()
使用例

class classA {
    required init() {
        var xx = 25
        print(xx)
    }
}
 
class classB: classA {
    required init() {
        var yy = 40
        print(yy)
    }
}
 
let cftA = classA()
let cftB = classB()

結果
25
40
25

Swift

Posted by arkgame