swift class struct内存存储模型
2016-07-26 本文已影响123人
Helen_2423
示例代码:
struct SPoint{
var x:Int
var y:Int
}
class RPoint{
var x:Int
var y:Int
static var max=100
init(x:Int,y:Int){
self.x=x
self.y=y
}
}
var sp=SPoint(x:10,y:20)
var rp=RPoint(x:10,y:20)
sp rp在内存中的存储模型
struct SCircle{示例代码:
var center:RPoint
var radius:Int
}
class RCircle{
var center:RPoint
var radius:Int
init(center:RPoint, radius:Int){
self.center=center
self.radius=radius
}
static var min=RPoint(x:0,y:0)
}
var sc=SCircle(center:rp, radius:10)
var rc=RCircle(center:rp, radius:100)