The same concept and procedure can be applied which is suggested by Reegan for creation and implementation of interface in the C++, C also follow the same the procedure of defining the structure which is an user defined data type in C programming.
An example of creating Interface in c language would be as follows -
Code:
struct Comp
{
int (*compareTo)(void* num1) = 0;
};
struct Fbar
{
int (*compareTo)(void* num1);
int val1;
int val2;
int val3;
};
void InitFbar(struct Fbar* this)
{
this->compareTo = ;
this->val1= 0;
this->val2 = 1;
this->val3 = 2;
}
Bookmarks