V
Vicent Giner-Bosch
Hello.
Say I want to define a struct/type which has several items inside it,
one of them being (a pointer to) a function.
I would do it like this:
typedef struct my_struct {
double (* function_one) (double x) ;
int another_element ;
double another_one ;
} my_struct ;
And when I want to create a new variable/object with that data type, I
would do it like this:
my_struct one_example ;
one_example.function_one = &F ;
one_example.another_element = 3 ;
one_example.another_one = 3.1415 ;
Where F is a previously defined function, something like this:
double F (double x) ;
Is this right?? Is the first time I am trying to do something like
this.
Thank you in advance.
Say I want to define a struct/type which has several items inside it,
one of them being (a pointer to) a function.
I would do it like this:
typedef struct my_struct {
double (* function_one) (double x) ;
int another_element ;
double another_one ;
} my_struct ;
And when I want to create a new variable/object with that data type, I
would do it like this:
my_struct one_example ;
one_example.function_one = &F ;
one_example.another_element = 3 ;
one_example.another_one = 3.1415 ;
Where F is a previously defined function, something like this:
double F (double x) ;
Is this right?? Is the first time I am trying to do something like
this.
Thank you in advance.