String as argument

Apr 8, 2014 at 12:46pm
Hi everyone,

I have a function which send a string as argument to a txt file, like the following:

1
2
3
4
5
void Fprint(... ofstream& myfile, const string a, const int b)
    ......
    myfile << "name: " << a << " age:" << b << "\\" << endl;
    ......
    }

However, my IDE (msvc12.0) popup an error about the << before a, by citing "No operator matches these operands"...

Could anyone please tell me for what reason this is?

Thanks in advance!
Apr 8, 2014 at 12:53pm
Did you #include <string> ?
Apr 8, 2014 at 1:00pm
Got it! Just forgot this thing...
Thanks! :)
Topic archived. No new replies allowed.