Jump to content

[C++] C269 Error Visual Studio 2015

Go to solution Solved by manon_gfx,

In order to use string, you have to include <string>

Simply add this: #include <string>

 

Sometimes an STL file will include other STL files, but sometimes only parts. It is a good rule to just include everything you need.

Hi,

So I'm learning C++ and for some reason I keep on getting the error in the title when I'm compiling this:

 

#include "stdafx.h"#include <iostream>using namespace std;int main(){    string mystring = "Test";    int a = 2;    cout << a;}

 

It's a console app.

Link to comment
https://linustechtips.com/topic/413706-c-c269-error-visual-studio-2015/
Share on other sites

Link to post
Share on other sites

@NeatSquidYT

Is that the only error the compiler throws?

plz paste the full error message verbatim 

Severity    Code    Description    Project    File    Line

Error    C2679    binary '<<': no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)    ConsoleApplication1    c:\users\myles\documents\visual studio 2015\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp    10

 

Link to post
Share on other sites

In order to use string, you have to include <string>

Simply add this: #include <string>

 

Sometimes an STL file will include other STL files, but sometimes only parts. It is a good rule to just include everything you need.

Link to post
Share on other sites

In order to use string, you have to include <string>

Simply add this: #include <string>

 

Sometimes an STL file will include other STL files, but sometimes only parts. It is a good rule to just include everything you need.

Thank you very very much :) I'm going to the library tomorrow to get a C++ book so I don't have to use guides that don't tell me how to do shit :P

Link to post
Share on other sites

Thank you very very much :) I'm going to the library tomorrow to get a C++ book so I don't have to use guides that don't tell me how to do shit :P

 

This includes book recommendations so you're not picking one at random (not all books are good after all). Try to see if there's a copy of a recommended book at your library.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×