Last active
December 23, 2015 22:59
-
-
Save CocoaBeans/6707387 to your computer and use it in GitHub Desktop.
OOP in C Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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