C++ is famous… or infamous for its complex initialization syntax. In this article, I’ll show you around 20 ways to initialize simple std::string variables. Can we somehow make it easier to understand?
Default values Have a look:
void foo() { std::string str0; std::string str1 {}; } We have two local variables (with automatic storage duration), str0 is default initialized, while str1 is value initialized.