用法

作者: 老公123 | 来源:发表于2018-11-10 11:37 被阅读0次

    letPers =Person()

    Pers.eat()

    letTeaC =Teacher()

    TeaC.teach()

    varStd:Student? =Student(name:"70kg", age1:"22岁")

    Std?.name = "小刚"

    Std?.show()

    Std = nil


    funceat() {

            print("吃饭")

        }

    functeach() {

            print("上课")

            super.eat()

        }

    varname:String="小明"{

            willSet(newValue){

                print("新名:\(newValue)")

            }

            didSet{

                print("旧名:\(oldValue)")

            }

        }

        overridefunceat() {

            print("吃了早餐")

        }

       private(set) var weight:String = "70千克"

        funcshow() {

            print("体重\(weight)")

        }

        lazyvarage:String="22岁"

        init(name:String,age1:String) {

            super.init()

            self.weight= name

            self.age= age1

        }

      public  funcshow1()  {

        print("name:\(name), weight:\(weight), age:\(age)")

        }

        deinit {

            self.age=""

            self.name=""

            print("调用了析构函数")

        }

    相关文章

      网友评论

          本文标题:用法

          本文链接:https://www.haomeiwen.com/subject/jtdzxqtx.html