vendredi 6 septembre 2019

Usage of Explicit Constructors, while the parameters are passed by reference [duplicate]

This question already has an answer here:

I have a Class with a constructor taking 2 std::string parameters by reference. In this case, does it make sense to change the constructor into an explicit one?

struct Foo { Foo(std::string& a, std::string& b); };
struct Bar { explicit Bar(std::string& a, std::string& b); };

In the above code, What would be the best thing in Bar from Foo?

Aucun commentaire:

Enregistrer un commentaire