avoiding the tedium of optional parameters
问题 If I have a constructor with say 2 required parameters and 4 optional parameters, how can I avoid writing 16 constructors or even the 10 or so constructors I\'d have to write if I used default parameters (which I don\'t like because it\'s poor self-documentation)? Are there any idioms or methods using templates I can use to make it less tedious? (And easier to maintain?) 回答1: You might be interested in the Named Parameter Idiom. To summarize, create a class that holds the values you want to