Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
| To | Do this |
|---|---|
| Create a property for a C++ class. | Use the __property keyword with get and set methods. For example:
__property void set_Weight(int n) { ...}
__property int get_Weight() { ... } |
| Implement a read-only property. | Implement only the get method. |
| Implement a write-only property. | Implement only the set method. |
| Implement an indexed property. | Implement a property whose get and set methods take parameters that are used to determine which value to get or set. For example:
__property void set_Pay(Person*, Amount*);
__property Amount* get_Pay(Person*); |