I put several checkboxes on the form to test function. Each checkbox represent one FLAG. My question is how to pass to function different number of flags each time ?
I'm not sure what you're trying to achieve but I think you want that part(parameter) dynamic. You can then check using a for loop and switch-case statements. Or use an observer type of pattern.
I put several checkboxes on the form to test function.
Each of those boxes is either checked or unchecked. In other words each flag is either true or false, but always present. As such, there is always the same number of flags.
It seems that each flag represents specific, named property. The function has to know the properties too.
1 2 3 4 5 6 7 8 9 10
enumclass Flag { FOO, BAR };
void function( const std::map<Flag, bool> & flags ) {
bool barstate { false }; // default
auto flag = flags.find( BAR );
if ( flags.end() != it ) {
// state of bar was given
barstate = *it;
}
...