I have a struct with many members of the same type, like this
struct VariablePointers {
VariablePtr active;
VariablePtr wasactive;
VariablePtr filename;
};
The problem is that if I forget to initialize one of the struct members (e.g. wasactive
), like this:
VariablePointers{activePtr, filename}
The compiler will not complain about it, but I will have one object that is partially initialized. How can I prevent this kind of error? I could add a constructor, but it would duplicate the list of variable twice, so I have to type all of this thrice!
Please also add C++11 answers, if there's a solution for C++11 (currently I'm restricted to that version). More recent language standards are welcome too, though!