How to initialize an array of struct in C++?
问题 I have the following struct in my C++ code (I am using Visual Studio 2010): struct mydata { string scientist; double value; }; What I would like to do is to be able to initialize them in a quick way, similar to array initialization in C99 or class initialization in C#, something á la : mydata data[] = { { scientist = "Archimedes", value = 2.12 }, { scientist = "Vitruvius", value = 4.49 } } ; If this is not possible in C++ for an array of structs, can I do it for an array of objects? In other