<< operator not recognized

I finally tracked down a bug that seems to be messing with the definition of a string. What in the following code is wrong? It will not compile or run, and the message I keep getting is 'no such operator', referring to the <<.



#include <iostream>
using namespace std;

int main (){

string str = "Hello, World!";
cout << str;

return 0;
}

Edit: I also attempted the following code in the main body.

std::string str = "Hello, World!";
std::cout << str;
Last edited on
Did you try to include the proper header file to use the <string> class?
Last edited on
Wow. I've been staring at this for an hour and missed that. Thanks!
Topic archived. No new replies allowed.