Q&A - C++ Initialization -- Bartlomiej Filipek

Last time I showed a couple of questions about initialization. Try them here if you haven’t already. In this article, I’ll show you the answers and add more notes about initialization in C++.

Q&A - C++ Initialization

by Bartlomiej Filipek

From the article:

Will this code work in C++11?
struct User { std::string name = "unknown"; unsigned age { 0 }; };
User u { "John", 101 };
  1. Yes, the code compiles in C++11 mode.
  2. The code compiles starting with C++14 mode.
  3. The code doesn’t compile even in C++20.

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.