////////////////////////////////////////////////////////////////////// // MoreFunctionalProp.cpp - 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 // ////////////////////////////////////////////////////////////////////// #ifdef TEST_MOREFUNCTIONALPROP #include "MoreFunctionalProp.h" #include #include class X { public: MFProperty number; MFProperty name; }; int main() { std::cout << "\n Demonstrating MFProp"; std::cout << "\n ======================"; X x; x.name = "Freddy"; x.number = 12345.432; std::cout << "\n x.name = " << x.name; std::cout << "\n x.number = " << x.number; std::cout << "\n after setting new values for X properties:"; x.name = "Akash"; x.number = 2; std::cout << "\n x.name = " << x.name; std::cout << "\n x.number = " << x.number; // Using T methods requires a get() to explicitly return the T value. // The compiler will only apply one operation here, but two would // be required, e.g., cast to std::string then call of size() method. std::cout << "\n size of x.name = x.name.get().size() = " << x.name.get().size(); std::cout << "\n\n"; return 0; } #endif