Swift学习之类与结构体
定义 定义 基本可以按照C++理解 //成员必须有默认值,要么直接赋值,要么构建函数中赋初值; //常量成员只能初始化一次,同上 struct Resolution { var width = 0 var height = 0 } class VideoMode { var resolution = Resolution() var interlaced = false var frameRate = 0.0 var name: String? } let someResolution = Resolution() let someVideoMode = VideoMode() print("The width of someResolution is \(someResolution.width)") print("The width of someVideoMode is \(someVideoMode.resolution.width)")