Click here to Skip to main content
15,887,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
#include

using namespace std;

int main() {

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

cout << text1 << endl;


system("pause");
}

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!
Posted
Updated 8-Feb-19 1:46am
v2
Comments
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

You need to include <string>:
C++
#include<string>
 
Share this answer
 
Comments
Member 14135996 8-Feb-19 7:54am    
Thank you mate!
CPallini 8-Feb-19 7:56am    
5.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900