A little question about operators...

I have this code:

awi_clog("Unknown command: " << command);

Which uses the function:

1
2
3
string awi_clog(string awi_clog_text){
        std::cout << awi_time() << awi_clog_text << endl;
};


However, problem is, << is not the operator to use here, is it? I want to combine that variable with my string.. Like in PHP: echo("hello " . $var);

Thanks in advance,

- Zor

Edit: And the compile error,

1
2
./src/main.cpp: In function âint main()â:
./src/main.cpp:80: error: no match for âoperator<<â in â"Unknown command: " << commandâ
Last edited on
You could do

 
awi_clog("Unknown command: " + command);
Yeah, you need to add the strings.
When you bitshift the command string with "Unknown command: " you will get one screwed up piece of data.
Last edited on
Ah, okay. Thanks guys. <3
Topic archived. No new replies allowed.