M
Marc Thrun
Hello,
I've got a few questions:
1) Given the two structs
struct A {
int x;
};
and
struct B {
struct A y;
int z;
};
is it ok to treat a "pointer to an object of type struct B" as a
"pointer to an object of type struct A"?
(I think someone asked something like this some time ago, but
unfortunately I can't find the article anymore)
2) When I now have a function pointer of type
void (*fpa)(struct A *, int);
and a function pointer of type
void (*fpb)(struct B *, int);
and the corresponding functions
void fa(struct A*,int);
and
void fb(struct B*,int);
is it ok to assign a "pointer to fa" to fpb and call the function
through fpb with a "pointer to an object of type struct B" as the first
parameter?
Thanks in advance
Marc Thrun
I've got a few questions:
1) Given the two structs
struct A {
int x;
};
and
struct B {
struct A y;
int z;
};
is it ok to treat a "pointer to an object of type struct B" as a
"pointer to an object of type struct A"?
(I think someone asked something like this some time ago, but
unfortunately I can't find the article anymore)
2) When I now have a function pointer of type
void (*fpa)(struct A *, int);
and a function pointer of type
void (*fpb)(struct B *, int);
and the corresponding functions
void fa(struct A*,int);
and
void fb(struct B*,int);
is it ok to assign a "pointer to fa" to fpb and call the function
through fpb with a "pointer to an object of type struct B" as the first
parameter?
Thanks in advance
Marc Thrun