Straight into business: I have code looking roughly like this:
char* assemble(int param)
{
char* result = "Foo" << doSomething(param) << "bar";
return result;
}
Now what I get is:
error: invalid operands of types ‘const char [4]’ and ‘char*’ to binary ‘operator<<’
Edit:
doSomething returns a char*.
So, how do I concatenate these two?
Additional info:
Compiler: g++ 4.4.5 on GNU/Linux 2.6.32-5-amd64
<<groups left-to-right, not right-to-left. So when you've seenstd::cout << a << b << c, that doesn't mean "concatenate a, b and c and write the result tostd::cout", and<<is not a concatenation operator. It means(((std::cout << a) << b) << c), that is "write each in turn of a, b and c tostd::cout".operator<<for streams returns the stream itself, precisely in order to support this chaining.