Skip to content

Instantly share code, notes, and snippets.

@CocoaBeans
Last active Dec 23, 2015
Embed
What would you like to do?
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