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 << value1 << '\n';
}
please point out if there is a way to make it possible or if it is not possible then why?
thank you.
I want to receive an integral value from the user and create a variable depending on the value that they entered.
for example if they entered 56 then an integer variable will be created. and if they entered 56.78 then a double variable will be created since it is a lateral.