Skip to content

Instantly share code, notes, and snippets.

@CocoaBeans
Last active December 23, 2015 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CocoaBeans/6707387 to your computer and use it in GitHub Desktop.
Save CocoaBeans/6707387 to your computer and use it in GitHub Desktop.
OOP in C Example
struct {
int (*AND_function_ptr)(int, int);
int (*math_funct_ptr)(float, char, float);
int (*comp_funct_ptr)(double);
int (*regul_funct_ptr)(char*, char*, int);
}functions;
int AND_function (int parameter1, int parameter2)
{
}
int math_funct (float parameter1, char parameter2, float parameter3)
{
}
int comp_funct (double parameter)
{
}
int regul_funct (char *parameter1, char *parameter2, int parameter3)
{
}
int main (int argc, char **argv)
{
functions f;
//Assign function pointers to functions
f.AND_function_ptr = AND_function;
f.math_funct_ptr = math_funct;
f.comp_funct_ptr = comp_funct;
f.regul_funct_ptr = regul_funct;
//Calling functions addressed by pointers
f.AND_function_ptr (10,15);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment