#pragma once ////////////////////////////////////////////////////////////////////// // MoreFunctionalProp.h - has most of the functionality needed, // // but you have to call get() to apply // // a method to one of these properties. // // // // Jim Fawcett, CSE687 - Object Oriented Design, Fall 2018 // ////////////////////////////////////////////////////////////////////// #include template class MFProperty { public: MFProperty() {} MFProperty(const T& t) { // copy construct Property from T instance set(t); } virtual ~MFProperty() {} T operator=(const T& t) // assign t to the T element of property { set(t); return get(); } operator T() { std::cout << "\n cast operation"; return get(); } virtual void set(const T& t) { t_ = t; } virtual T get() { return t_; } protected: T t_; }; ///////////////////////////////////////////////////////////////////// // operator<< // - global operator defined for MFProperty template std::ostream& operator<<(std::ostream& out, MFProperty& p) { out << p.get(); return out; }