Compiler Problem
My compiler(VC++ 6) never accepts cin >> str1 if str1 is declared as a string .
the following program gives error.
#include <iostream.h>
#include <string>
using namespace std;
int main() {
string testStr;
cout << "enter string";
cin >> testStr;
return 0;
}
C:\Program Files\Microsoft Visual Studio\MyProjects\Learning\test2\test_loop.cpp(9) : 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::allo
cator<char> >' (or there is no acceptable conversion)
Solutions :
Change "#include <iostream.h>" to "#include <iostream>". Use the newer standard headers such as iostream, string and fstream instead of iostream.h, string.h and fstream.h. Mixing older and new style headers causes compilation problems such as I experienced.
thanks
