This question already has an answer here:
I was playing around with some code for reading lines from cin into strings that my gf gave me, and I noticed that in visual c++ std::getline()
requires #include <string>
, while in GCC (g++) it does not require #include <string>
. What is the reason for this?
Example:
This works in g++ but not Visual c++:
#include <iostream>
int main() {
std::string test;
std::getline(std::cin, test);
return 0;
}
This works in Visual c++ (and g++):
#include <iostream>
#include <string>
int main() {
std::string test;
std::getline(std::cin, test);
return 0;
}