#include #include #include template class prompt: private std::pair { public: prompt(const std::string& text, T& target): std::pair {text, target} {} friend std::istream& operator >> (std::istream& source, prompt target) { auto request = source.tie(); if (request) { (*request) << target.first; } source >> target.second; return source; } }; int main(int argc, char* argv[]) { int x = 5; std::cin >> prompt("Enter a number: ", x); std::cout << x << std::endl; return 0; }