Issues with new compliler
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Issues with new compliler

  1. #1
    Join Date
    Aug 2006
    Location
    Dallas, TX
    Posts
    46

    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

  2. #2
    Join Date
    Aug 2006
    Location
    Dallas, TX
    Posts
    46

    Re: Issues with new compliler

    Ok I found my own issue. Thanks if you looked anyway. Visual Studio requires an include of
    #include <string>

  3. #3
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,286

    Re: Issues with new compliler

    I notice that you neglected to #include <string> yet you use std::string.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  4. #4
    Join Date
    Apr 1999
    Posts
    27,427

    Re: Issues with new compliler

    Quote Originally Posted by cypher5783 View Post
    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center