the MSDN documentation page. // declspec_property.cpp struct S { int i; void putprop(int j) { i = j; } int getprop() { return i; } __declspec(property(get = getprop, put = putprop)) int the_prop; }; int main() { S s; s.the_prop = 5; return s.the_prop; } D class Pen { private int m_color; // private field // public get property public int color () { return m_color; } // public set property public void color (int value) { m_color = value; } } auto pen = new Pen; pen.color = ~pen.color; // bitwise complement // the set property can also be used in expressions, just like regular assignment int theColor = (pen.color = 0xFF0000); In D version 2, each property accessor or mutator must be marked with @property: class Pen { private int m_color; // private field // public get property @property public int color () { return m_color; } // public set property @property public void color (int value) { m_color = value; } } Delphi/Free Pascal type TPen = class private FColor: TColor; function GetColor: TColor; procedure SetColor(const AValue: TColor); public property Color: Integer read GetColor write SetColor; end; function TPen.GetColor: TColor; begin Result := FColor; end; procedure TPen.SetColor(const AValue: TColor); begin if FColor <> AValue then FColor := AValue; end; // accessing: var Pen: TPen; // ... Pen.Color := not Pen.Color; (* Delphi and Free Pascal also support a 'direct field' syntax - property Color: TColor read FColor write SetColor; or property Color: TColor read GetColor write FColor; where the compiler generates the exact same code as for reading and writing a field. This offers the efficiency of a field, with the safety of a property. (You can't get a pointer to the property, and you can always replace the member access with a method call.) *) eC class Pen { // private data member Color color; public: // public property property Color color { get { return color; } set { color = value; } } } Pen blackPen { color = black }; Pen whitePen { color = white }; Pen pen3 { color = { 30, 80, 120 } }; Pen pen4 { color = ColorHSV { 90, 20, 40 } }; F# type Pen() = class let mutable _color = 0 member this.Color with get() = _color and set value = _color <- value end let pen = new Pen() pen.Color <- ~~~pen.Color JavaScript