/* * Copyright (c) 2008 * Evan Teran * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appears in all copies and that both the * copyright notice and this permission notice appear in supporting * documentation, and that the same name not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. We make no representations about the * suitability this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include #include "Property.h" class TestClass { public: // make sure to initialize the properties with pointers to the object // which owns the property TestClass() : prop1_(0), prop3_(0.5), prop1(this), prop2(this), prop3(this) { } private: int getProp1() const { return prop1_; } void setProp1(int value) { prop1_ = value; } int getProp2() const { return 1234; } void setProp3(double value) { prop3_ = value; } int prop1_; double prop3_; public: PropertyRW prop1; PropertyRO prop2; PropertyWO prop3; }; int main() { unsigned int a; TestClass t; t.prop1 = 10; a = t.prop1; t.prop3 = 5; a = t.prop2; std::cout << a << std::endl; }

AltStyle によって変換されたページ (->オリジナル) /