I'm using MS VC++ 6.0 Enterprise, which sucks. But alas, moving on.
The line I have currently is:
cin >> input; //input is declared as std::string input;
Error:
g:\c++\jarvis\jarvis.cpp(26) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversion)
I know the compiler is ancient, but it's the one my school makes me use. If I were doing this myself I'd use my copy of Express. but anyway. I will try it with std::getline
No, I don't think getline(istream,string) is in std. For instance, the following code worked fine.
getline(std::cin,name);
This code uses std::getline(), due to argument-dependent lookup (whenever an unqualified function call is made, the compiler first looks in the namespace of the arguments. That's why it's possible to write std::cout << name and not std::operator<<(std::cout, name) )
g:\c++\jarvis\jarvis.cpp(12) : error C2039: 'getline' : is not a member of 'std'
g:\c++\jarvis\jarvis.cpp(12) : error C2873: 'getline' : symbol cannot be used in a using-declaration
g:\c++\jarvis\jarvis.cpp(27) : error C2039: 'getline' : is not a member of 'std'
g:\c++\jarvis\jarvis.cpp(27) : error C2065: 'getline' : undeclared identifier
I suggest that you don't use std::getline(std::istream,std::string), then. My IDE seems to support either std::getline or getline, without a usingnamespace std;.
The difference is that the first method will give you everything up until the first whitespace. The second one will give you everythign up until the first new line.
So in the code I just posted above, replacing getline with cin should still do what I want?
Tried it, got this:
error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversion)