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 };
- Yes, the code compiles in C++11 mode.
- The code compiles starting with C++14 mode.
- The code doesn’t compile even in C++20.
Add a Comment
Comments are closed.