I am a beginner in c++ so thank you in advance for help. My question is: what is the correct way to call the function that expects std::istream&.
Tried it with read(std::cin); , but I get error from compiler.
typedef double Element;
template<typename T>
std::list<T> read(std::istream& i) {
Element input;
std::list<Element> l;
while(i>>input) {
l.push_back(input);
}
return l;
}
>Solution :
This is not related to the std::istream& parameter.
The issue is that the function is a function template that requires an explicit template argument determining the type that is supposed to be read from the stream, e.g.:
read<int>(std::cin)
The error message from the compiler should be telling you something like that as well.