Click on stack.h to get source.
/* File: CExamples/OO_pgm_in_C_new/stack.h */
/* This is the abstract data object; initialize by calling new_stack
remove by calling delete_stack */
typedef struct stackstruct
{ void *objptr; /* address of data structure */
/* abstract methods;
the actual data structure of the stack is accessed as self->objptr
In C++ self is the keyword this; self is from Smalltalk */
int (*is_empty)(struct stackstruct* self); /* returns 0 if *self is empty */
void(*push) (int, struct stackstruct* self);
int (*pop) (struct stackstruct* self);
/* object manipulation; see also new_stack, delete_stack below */
struct stackstruct* (*clone) (struct stackstruct* self); /* make a copy */
} stack, *stackptr;
/* a generic function */
extern void print_stack(stack s);
/* the following functions are specific to the data structure used:
therefore, there can only be one data structure used by
a program, which is a restriction. One could overcome
this restriction by placing pointers to new and delete inside
struct stackstruct; however, in the current model the
function main() is also generic via the linking mechanism.
for more on these different forms of genericity, see:
http://www.math.ncsu.edu/~kaltofen/bibliography/index.html#EKM96
*/
extern stackptr new_stack(void);
extern void delete_stack(stackptr);