// MT1-QQ3.cpp : This file contains the 'main' function. Program execution begins and ends there. // template class Property { public: Property(T t = T()) { t_ = t; } T operator()() { return t_; } void operator()(T t) { t_ = t; } template void operator()(U u, A a) { (t_.*u)(a); } template void operator()(U u) { (t_.*u)(); } private: T t_; }; #include #include #include using vecStr = std::vector; int main() { //std::vector vecStr{ "one", "two", "three" }; //Property> strProp(vecStr); Property strProp({ "one", "two", "three" }); std::vector temp = strProp(); temp.push_back("four"); strProp(temp); using PtrFun1 = void (vecStr::*)(std::string&&); PtrFun1 pushBack = &vecStr::push_back; strProp(pushBack, "five"); strProp(pushBack, "six"); for (auto item : strProp()) std::cout << item << " "; std::cout << "\n"; using PtrFun0 = void (vecStr::*)(); PtrFun0 popBack = &vecStr::pop_back; strProp(popBack); for (auto item : strProp()) std::cout << item << " "; std::cout << "\n"; }