__declspec(property)
Go Up to Keywords, Alphabetical Listing Index
Category
Modifiers (C++), Keyword Extensions, Storage Class Specifiers (C++)
Syntax
__declspec( property( get=get_func_name ) ) declarator __declspec( property( put=put_func_name ) ) declarator __declspec( property( get=get_func_name, put=put_func_name ) ) declarator
Note: The __declspec(property) specifier is supported for compatibility with Microsoft. This page is adapted from the MSDN page for your convenience. For the RAD Studio libraries, use the __property keyword extension for C++Builder.
This attribute can be applied to nonstatic "virtual data members" in a class or structure definition. The compiler treats these "virtual data members" as data members by changing their references into function calls.
When the compiler sees a data member declared with this attribute on the right of a member-selection operator ("." or "->"), it converts the operation to a get or put function, depending on whether such an expression is an l-value or an r-value. In more complicated contexts, such as "+=", a rewrite is performed by doing both get and put.
This attribute can also be used in the declaration of an empty array in a class or structure definition.
Example
__declspec(property(get=GetX, put=PutX)) int x[];
The above statement indicates that x[] can be used with one or more array indices. In this case:
i=p->x[a][b];
will be turned into:
i=p->GetX(a, b);
and
p->x[a][b] = i;
will be turned into:
p->PutX(a, b, i);