All pastes #930622 Raw Edit

Mine

public text v1 · immutable
·published 2008-03-06 19:03 UTC
rendered paste body
template < class T >
class Property
{   
    public:
        virtual void set(T const& x) { t = x; }
        virtual T get() { return t; }
    public:
        void operator = (T const& x) { set(x); }
        operator T() { return get(); }
        T operator() () { return get(); }
        T operator() (T const &x) { set(x); return x; }
    private:
        T t;
};

class Data
{
    public:
        class KeyProperty : public Property<int>
        {
            void set(int const& x) { printf("SET!\n"); }
            int get() { printf("GET!\n"); return 0; }
        } p;
};


int main(int argc, char* argv[])
{
    Data d;
    int x = 0;
    d.p = x;
    x = d.p;
    d.p(x);
    x = d.p();
    getch();
    return 0;
}