Damage and Cost are integers, but as you can see in the code below I want to concatenate them with a string (if that’s the right word). How can I do this?
class Weapon : Shopable{
private:
int Damage;
public:
std::string getDesc() const{
return getName()+"\t"+Damage+"\t"+Cost;
}
};
Provide yourself with this template:
You can then say:
Note this is pretty much equivalent to Boost’s
lexical_cast, and to similar facilities in the upcoming standard. Also note that this function trades performance for convenience and type-safety.