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.`
When all 'parameters' have been set, another function is called (let us name it `Execute`) that takes no args:
// 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前端其它相关文章！