mardi 9 juillet 2019

function call parameter, char * vs string default constructor

While calling a function/method in C++11 and above, which one is better (if any difference)?

Lets assume this function/method:

void func(std::string s) { ... }

Which one is best between the following?

func(std::string())

or

func("")

And more generally, is there any advantage to always call the constructor explicitly during initialization or parameter passing?

Aucun commentaire:

Enregistrer un commentaire