概述
struct CenterPointer{
var x=0, y=0
}
func + (left:CenterPointer, right:CenterPointer) -> CenterPointer{
return CenterPointer(x:left.x+right.y, y:left.y+right.y)
}
//
//let pointer1 = CenterPointer(x:2, y:3)
//let pointer2 = CenterPointer(x:4, y:5)
//let pointer3 = pointer1 + pointer2
//
//
//
//func == (left:CenterPointer, right:CenterPointer) -> Bool {
// return (left.x == right.x) && (left.y == right.y)
//}
//
//func != (left:CenterPointer, right:CenterPointer) -> Bool {
// return !(left == right)
//}
//
//
//print(pointer1 == pointer1)
//
//
func += (inout left:CenterPointer, right:CenterPointer){
left = left + right
}
var pointer1 = CenterPointer(x:2, y:3)
var pointer2 = CenterPointer(x:4, y:5)
pointer1 += pointer2
最后
以上就是彩色百褶裙为你收集整理的笔记一 运算符重定义的全部内容,希望文章能够帮你解决笔记一 运算符重定义所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复