|
-
January 14th, 2003, 09:45 AM
#1
help... error with string
hi, i am just going through accelerated cpp. Using VC, I have written the below code as a console application :
#include <iostream.h>
#include <string>
using namespace std;
int main()
{
string name;
cout << "enter ur name " << endl;
cin >> name;
return 0;
}
On compilation, getting the below error for cin >> name; its exactly as the book says. What is happening here.. please help!!!
f:\sunita\work\helloo\helloo.cpp(8) : 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 conver
-
January 14th, 2003, 10:02 AM
#2
It should be :
Code:
#include <iostream> // no .h
You should you the standard headers, not the
old-style headers from before ISO standardization.
-
January 14th, 2003, 10:06 AM
#3
Thanks
thanks for pointing it out to me..
-
January 14th, 2003, 12:19 PM
#4
... and if the book you're using does have iostream.h in its examples, ditch it and get a book by someone who knows what he's talking about.
Correct is better than fast. Simple is better than complex. Clear is better than cute. Safe is better than insecure.
-- Sutter and Alexandrescu, C++ Coding Standards
Programs must be written for people to read, and only incidentally for machines to execute.
-- Harold Abelson and Gerald Jay Sussman
The cheapest, fastest and most reliable components of a computer system are those that aren't there.
-- Gordon Bell
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|