class mypoint{
var x:Int =1;
var y:Int =1;
init(#x:Int,#y:Int){
self.x = x;
self.y = y;
}
var description:String{//在这里稍有贪心,做一描述成员get变量
get{
return "x=\(x),y=\(y)";
}
}
}
func +(left:mypoint,right:mypoint)->mypoint{
return mypoint(x: left.x+right.x,y: left.y+right.y);
}
var p1:mypoint =mypoint(x: 1,y:1);
var p2:mypoint =mypoint(x: 2,y:2);
println((p1+p2).description);
原文链接:https://www.f2er.com/swift/326861.html