Having a structure like this in C++11:
struct von
{
std::string Name;
unsigned int ID;
std::vector<std::string> Checks;
};
Should it be initialized like this:
von v = {"",0,{}};
Or like this:
von v = {};
Both ways seem to work, but the compiler warns about -Wmissing-field-initializers on the latter example.
Edit:
Here are my compiler options:
g++ main.cpp -ansi -Wall -Wextra -Weffc++ -std=c++0x
I’m using g++ (Debian 4.6.2-12) 4.6.2
This doesn’t require initializer_list at all and work perfectly fine with C++03. Edit: (Ok, for the initialization of the vector you need C++11) In a struct or array initialization, all not explicitly given values are zero-initialized, so if that’s what you want = {}; will work just fine.