Function with variable number of args in C and a design-oriented question

I have a C function named `SetParams(...)` with a variable number of arguments. This function sets up a static data structure (let us name it `Data`). `SetParams` is used with pairs of arguments, e.g. `SetParams("paramA", paramA_value, "paramB", paramB_value)` etc. It can also be called many times, `e.g.` SetParams("paramA", paramA_value); SetParams("paramB", paramB_value); ... When all 'parameters' have been set, another function is called (let us name it `Execute`) that takes no args: Execute(); // uses data from static 'Data' and performs error_handling and execution I was wondering if I could structure this kind of code in a more object-oriented way. So, I would like some advice, especially for error-handling, since some pairs of args may contradict others.
What exactly are you trying to do? Any reason you don't just call "SetParams" multiple times and push the results on to a stack before calling execute which pops everything off the stack and uses them?

以上就是Function with variable number of args in C and a design-oriented question的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » CSS3 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准