swift 类继承

前端之家收集整理的这篇文章主要介绍了swift 类继承前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。




import Foundation


class Student{
    func sayHi()
    {
         print("student say hi")
    }

}

class Persion:Student{
    
    var _name:String
    
    init(name:String) {
        self._name = name
    }
    
    override func sayHi() {
        super.sayHi()
        print("say \(self._name)")
    }
}

var persion = Persion(name: "yihong")
persion.sayHi()

猜你在找的Swift相关文章