- '' 属性示例(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
|