如果我有一个带有2个必需参数和4个可选参数的构造函数,如果我使用默认参数(我不喜欢因为它很差),我怎么能避免编写16个构造函数,甚至编写10个左右我必须编写的构造函数自文档)?有没有使用模板的习语或方法我可以使用它来减少繁琐?(更容易维护?)
c++ constructor idioms optional-parameters
c++ ×1
constructor ×1
idioms ×1
optional-parameters ×1