I learn C ++, following the examples in the book, and after entering this and double checking, I keep getting error messages. I can’t understand what’s wrong. I am using Visual C ++ 2010 if that matters.
#include <iostream>
using namespace std;
int main()
{
cout << "Please enter two words:" << endl;
string b, c;
cin >> b >> c;
cout << "I understood: "
<< b << ", and "
<< c << endl;
cout << "Now, type in a whole line of text, "
<< "with as many blanks as you want:"
<< endl;
string wholeLine;
getline( cin, wholeLine );
cout << "I understood: \"" << wholeLine << "\"" << endl;
return 0;
}
There are four errors. Error Codes:
Error 1 error C2678: binary '→': operator not found that accepts a left operand of type 'std :: istream' (or not an acceptable conversion) i: \ helloworld.cpp 11
Error 2 C2679: binary '<<: operator not found that accepts the right operand of type' std :: string '(or not an acceptable conversion) i: \ helloworld.cpp 15
Error 3 error C3861: 'getline': identifier not found i: \ helloworld.cpp 25
4 C2679: '< <: , 'std::string' ( ) i:\helloworld.cpp 29