There doesn't seem to be a standard constructor so I've taken to doing the following
void myMethod(char delimiter = ',')
{
string delimiterString = 'x';
delimiterString[0] = delimiter;
// use string version ...
}
Is there a better way to do this?
std::string
has a constructor that will do it for you:
std::string delimiterString(1, delimiter);
The 1 is a size_t
and denotes the number of repetitions of the char
argument.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With