jeudi 21 septembre 2017

initialize a string size during declaration

suppose I have a class like this and I would like to create a string with a specific capacity. I tried doing the following but that did not work. Any suggestions ? I know I could do it in the constructor but would like to do it during the declaration if possible.

class foo
{
 std::string bar = std::string().resize(45);
}

Aucun commentaire:

Enregistrer un commentaire