阅读背景:

如何用多个构造函数参数初始化类?

来源:互联网 

I have a class that takes many arguments to create. It’s a sort of an audio processor that needs a sample rate, sample resolution, number of channels etc. Most of the parameters have sane defaults. And most of them should be only settable in the initializer (constructor), because it makes no sense to change them afterwards. I do not want to create a gargantuan initializer with all the parameters because (1) it would be huge and essentially it would only copy the passed values, doing no real work, and (2) the user would have to specify values for all the parameters. What’s a good way to solve this?I have a class that takes many arguments to cre




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: