I've been trying to figure this out and was wondering if I could get some feedback from the community.
Say I have the following interface:
then I inherit from it:
I can then implement the IDatabase interface by using:
Obviously I have missed out a couple of steps (notably linking the function pointers to the correct functions in the implementation file which have static scope).
I can then use it by doing:
does this look like something that you would be willing to use code wise? Any thoughts?
Say I have the following interface:
Code:
struct IBase
{
void * (*connect)(void *);
int (*disconnect)(void *);
} IBase;
then I inherit from it:
Code:
struct IDatabase
{
struct IBase *lpVtable;
void * (*add_user)(void *);
} IDatabase;
I can then implement the IDatabase interface by using:
Code:
struct IDatabase * new(void)
{
struct IDatabase *newStruct = malloc(sizeof(struct IDatabase));
if(newStruct == NULL)
{
// handle error
}
return newStruct;
}
I can then use it by doing:
Code:
struct IDatabase *db = new();
does this look like something that you would be willing to use code wise? Any thoughts?