【例题】属性

  勇芳 2017-3-31 6447

'' 属性示例(setter和getter属性使用相同的标识符)

type Rectangle
	as integer left, top, right, bottom

	declare property width( as integer )    '' setter
	declare property width( ) as integer    '' getter
end type

'' 设置宽度
property Rectangle.width( w as integer )
	this.right = this.left + w
end property

'' 检索宽度
property Rectangle.width( ) as integer
	return this.right - this.left
end property


dim as Rectangle rc = ( 10, 10, 50, 50 )

print rc.left, rc.top, rc.right, rc.bottom, "width: ";rc.width
rc.width = 100
print rc.left, rc.top, rc.right, rc.bottom, "width: ";rc.width


因国家互联网安全管理要求,关闭回帖功能。大家需要留言,请使用【勇芳软件客服】即时联系勇芳点此打开->>勇芳软件客服
返回
联系勇芳
发新帖 搜索 反馈 回顶部