0

I want to do something really simple: I have function that has string parameter and I want to chain it to some constant string, then output result to console like this:

void test(string s){
    cout << "Parameter of this function was: " << s;
}

In other languages chaining like this works, but in C++ the compiler is unhappy: error C2679: binary '<<': no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)

Marc Mutz - mmutz
  • 24,485
  • 12
  • 80
  • 90
Rasto
  • 17,204
  • 47
  • 154
  • 245

2 Answers2

6

You probably forgot to #include <string> or #include <iostream>.

Marc Mutz - mmutz
  • 24,485
  • 12
  • 80
  • 90
0

What version of Visual Studio are you using? Your code sample is correct C++ (as long as you have the appropriate "using namespace std;").

Putting similar code through g++ works fine.

MarkH
  • 101
  • 3