C2679 Error using C++ in Visual Studio - TechRepublic
Question
May 14, 2008 at 02:44 PM
borginva

C2679 Error using C++ in Visual Studio

by borginva . Updated 18 years, 2 months ago

Visual Studio 2008
> Empty solution
> New item (for code)

I am trying to find out why I am getting such an error. Nothing on the web shows me what I need to know on how to fix. Here is some simple code that should give me the output “TEST”:

#include
using namespace std;

int main()
{
const string s = “TEST.”;
cout << s << endl; return 0; } In doing that, this is the full error: error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'const std::string' (or there is no acceptable conversion) Now, even if I take away "const", I get the same error. Yes, this method works fine: int main() { int myScore = 100; cout << "Hello, world!" << endl; cout << myScore << endl; return 0; } I just can not figure out why "string" is giving me the error. Any help would be appreciated., I am trying to use this book but stuck because everything uses the strings as the above example, and I can not get past it. I hope this is all that is needed. Thank you.

This discussion is locked

All Comments