- 结构体
struct Resolution {
var width = 0
var height = 0
}
let vga = Resolution(width: 640, height: 480)
var cinema = vga
cinema.height = 460
print(cinema.height,vga.height) // 460 480
- 类
class VideoMode {
var resolution = Resolution()
var interlaced = false
var frameRate = 0.0
var name:String?
}
let ten = VideoMode()
ten.resolution = vga
ten.interlaced = true
ten.frameRate = 25.0
ten.name = "Roy"
var also = ten
also.frameRate = 30.0
print(ten.frameRate,also.frameRate) // 30.0 30.0
网友评论