-
January 2nd, 2013, 01:09 AM
#1
Issues with new compliler
I'm trying out a the new Visual Studio 2012 Express IDE. I've had no issues with previous versions of the Visual Studio IDE. But this one won't even compile simple programs for some reason. Maybe someone has some advice. Here is a small simple program I tried to compile and run and the associated errors.
Code:
#include <iostream>
using namespace std;
int main()
{
string words = "Something interesting and bizarre";
cout << words << endl;
words.insert(10, "seriously ");
cout << words << endl;
words.erase(19,16);
cout << words << endl;
words.replace(4, 5, "body");
cout << words << endl;
system("pause");
return 0;
}
Error 1 error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion) c:\users\noah\documents\visual studio 2012\projects\testing\testing\test.cpp 8 1 Testing
-
January 2nd, 2013, 01:17 AM
#2
Re: Issues with new compliler
Ok I found my own issue. Thanks if you looked anyway. Visual Studio requires an include of
-
January 2nd, 2013, 01:20 AM
#3
Re: Issues with new compliler
I notice that you neglected to #include <string> yet you use std::string.
-
January 2nd, 2013, 05:14 AM
#4
Re: Issues with new compliler
Originally Posted by cypher5783
Ok I found my own issue. Thanks if you looked anyway. Visual Studio requires an include of
It is not really a matter of what particular compiler requires to be included.
You are using the std::string class within your code. By not including <string>, the code is not guaranteed to compile. By including <string>, the code is guaranteed to compile, regardless of the brand of ANSI C++ compiler you're using, whether it is Visual C++, g++, etc.
Regards,
Paul McKenzie
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
|