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("调用了析构函数")
}