
The following is a class to emulate C# properties using C++: www.ezequal.com/chaos/libs/property.h example code: template < typename T > class Coord { private: T x, y; T get_X ( ) const { return x; } T get_Y ( ) const { return y; } void set_X ( const T & value ) { x = value; } void set_Y ( const T & value ) { y = value; } public: utils::GetSetProperty < Coord < T >, T > X; utils::GetSetProperty < Coord < T >, T > Y; Coord ( ) : X ( this, get_X, set_X ), Y ( this, get_X, set_X ) { } Coord ( T X, T Y ) : X ( this, get_X, set_X ), Y ( this, get_X, set_X ) { this->X = X; this->Y = Y; } }; The compiler appears to optimize out any calls between the property's use and the get/set functions. Any thoughts or suggestions for improvement? -Jason