Question Locked

C2679 Error using C++ in Visual Studio

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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.

4 replies

by Former member

add this line - #include .

Just by going on what you have put down, i do not know if it would work.

by Former member

NT.

This discussion is closed to new replies.