3 ms·
Thanks very much for the explanations, folks! One more follow-up question: what are reasons to prefer: std::string product; product = "not worked";
by kleiba 5y ago
Thanks very much for the explanations, folks! One more follow-up question: what are reasons to prefer:
std::string product;
product = "not worked";
i.e., separate declaration and initialization, as suggested by the grand-parent?
- dmitrykoval 5y agoFor this particular example direct initialization i.e. std::string product("not worked"); would be preferred, as you end up using one call to constructor instead of two: default constructor followed by the move assignment. https://en.cppreference.com/w/cpp/language/direct_initialization https://en.cppreference.com/w/cpp/language/direct_initializa... https://en.cppreference.com/w/cpp/language/move_assignment https://en.cppreference.com/w/cpp/language/move_assignment