Can I use template or auto keyword in cpp to create a variable that i can use with std:: cin to get a value from user?
Advertisements this line of code is wrong and won’t compile but i am wondering if it can be fixed. #include <iostream> template <typename T> auto getValue() { std::cout << "Enter an integral value: "; T value{}; std::cin >> value; // I would do input handing later return value; } int main() { auto value1{getValue()}; std::cout… Read More Can I use template or auto keyword in cpp to create a variable that i can use with std:: cin to get a value from user?