Hello,
Why it's not working and how to make it work?
Thank you.Code:string str = "hello" + " *** ";
Printable View
Hello,
Why it's not working and how to make it work?
Thank you.Code:string str = "hello" + " *** ";
-- thank you.
It's possible to avoid the explicit conversions I suggested. For example you can do this,
Here instead implicit conversions (from const char* to string) take place behind the scene.Code:string str = "hello";
str = str + " *** ";
If you know in advance that the string will become very long, it could make sense to call "reserve" upfront. This way there will be less memory reallocations during the string building process. But this is only important when it has to be quick.
> If you know in advance that the string will become very long, it could make sense to call "reserve" upfront. This way there will be less memory reallocations during the string building process. But this is only important when it has to be quick.
Actually, it does have to be fast, I'll keep "reserve" in mind, I am just not at the stage to optimize the strings -- thx.