Click here to Skip to main content
14,022,666 members
Rate this:
Please Sign up or sign in to vote.

using namespace std;

int main() {

string text1 = "Hello, this is a string";

cout << text1 << endl;


What I have tried:

This is the code that i wrote in Visual Studio.
I tried to run it, and then it said to me:

no operator “<<” matches these operands.
operand types are std::ostream << std::string.

I Need help!
Updated 8-Feb-19 1:46am
Rick York 8-Feb-19 17:45pm
Actually that is what the compiler said when you tried to compile the program. You have to compile and link the program before it can run.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You need to include <string>:
Member 14135996 8-Feb-19 7:54am
Thank you mate!
CPallini 8-Feb-19 7:56am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web01 | 2.8.190417.4 | Last Updated 8 Feb 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100