I have code as ff:
typedef double* (*DBLPTRFUNCPTR)(int) ;
typedef int* (*INTPTRFUNCPTR)(int) ;
typedef double (*DBLFUNCPTR)(int) ;
typedef int (*INTFUNCPTR)(int) ;
etc ....
typedef struct
{
double *data;
int size;
int numcols;
int currcol;
DBLPTRFUNCPTR New ;
VOIDFUNCPTR Destroy ;
DBLFUNCPTR GetItem ;
VOIDFUNCPTR2 SetItem ;
} FArray, *FArrayPtr;
How can I pass a "this" ptr (i.e. ptr to the struct to my
allocate/dealllocate functions so I can write code like this (Yes I know
it is a "no-brainer in C++, but I have to implement this in Ansi C -
Basically, I'm porting C++ code using STL vectors, and I need this
functionality as a "wrapper")
/* Sample code*/
void foo( void ) {
double tmp ;
FArray array ;
array.New(10) /* Allocate a 1D array with 10 rows */
array.SetItem(1)= 3.142 ;
tmp = array.GetItem(1) ;
array.Destroy() /* Free memory */
}
Many thanks in advance