Click here to Skip to main content
15,887,285 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
the problem it is giving is in << operator before str_3
it is saying

Error binary '<<': no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)

What I have tried:

std::string str_3 = "hello";
std::cout << "string str_3 using string class:"<< str_3 <<std::endl;
Posted
Updated 21-Jul-18 10:51am
v2
Comments
KarstenK 22-Jul-18 4:30am    
You missed to include the iostream. The error message is always talking to you ;-)

1 solution

This works just fine:
C++
using namespace std;

int main()
{
	string str_3 = "hello";
	cout << "string str3 using string class: " << str_3 << endl;

    return 0;
}

...so long as your "includes" include:
C++
#include <iostream>
#include <string>
 
Share this answer
 
v3

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