Question

Locked

C2679 Error using C++ in Visual Studio

By BorgInva ·
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 <iostream>
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 conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

What if you added this..

add this line - #include <string>.

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

Collapse -

Yes

by BorgInva In reply to What if you added this..

That was the ticket. Thank you.

Collapse -

No problem. :)

Back to Software Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums