菜鸡学Swift3.0 14.类

类 class 是引用类型

1.class 类的类型 { var 类的属性:类型...}

class Person {
    var firstName: String
    var lastName: String
    // 初始化
    init (firstName:String , lastName:String){
        self.firstName = firstName
        self.lastName = lastName
    }
}

2.类的初始化

var Person1 = Person(firstName:"jack" , lastName:"son")

3.类的使用

Person1.firstName

你可能感兴趣的:(菜鸡学Swift3.0 14.类)