//1.类的定义
//类由属性和方法构成
class Person{
//定义属性
var name:String = ""
var sex:String = ""
var age:Int = 0
//定义方法
func say(){
print("你好")
}
}
//2.实例化对象
var p1 = Person()
//访问属性和方法
p1.name = "张三"
p1.sex = "男"
p1.age = 18
print(p1.name)
print(p1.age)
//3.类是引用类型
var p2 = p1
p2.name = "小红"
p2.sex = "女"
p2.age = 13
//猜猜执行结果
print(p1.name)
print(p1.sex)
print(p1.age)
//4.如何判断是否引用了同一个实例
print(p1===p2)
let p3 = Person()
print(p1===p3)