“this” pointer in C (not C++)

后端 未结 7 1517
花落未央
花落未央 2020-12-24 09:42

I\'m trying to create a stack in C for fun, and came up with the idea of using struct to represent the stack. Then I add function pointers to the struct for push() and pop()

7条回答
  •  执念已碎
    2020-12-24 10:19

    Obviously you can have a Stack * member in the struct and then just initialize it with the address of the struct before you use the function pointers. Then make the Stack * a parameter on the function pointers.

提交回复
热议问题