Pseudo-generics in C

前端 未结 3 1654
北荒
北荒 2020-11-29 19:27

I need to implement some methods that do stuff with different kinds of number arrays. Usually, I\'d use generics for that job, but as C doesn\'t provide them, I\'m now tryin

3条回答
  •  無奈伤痛
    2020-11-29 20:00

    You can also use function pointers (Array of function pointers), other than a switch statement, and pass the argument of the switch as the index to the array.

提交回复
热议问题