Hallo MichaelB,
Mechnismen wie Vererbung bekommt man zwar nicht so ohne Weiteres umgesetzt, aber immerhin.
#include <stdlib.h>
#include <stdio.h>
struct s_parent {
int x;
};
struct s_child {
struct s_parent base;
int y;
};
#define S_PARENT(a) ((struct s_parent *)a)
int s_parent_multiply(struct s_parent *this) {
this->x *= 10;
}
int s_child_multiply(struct s_child *this) {
this->y *= 10;
}
int main(void) {
struct s_child x;
S_PARENT(&x)->x = 10;
x.y = 10;
s_parent_multiply(S_PARENT(&x));
s_child_multiply(&x);
printf("x: %d, y: %d\n",S_PARENT(&x)->x,x.y);
return EXIT_SUCCESS;
}
Grüße,
CK
--
Mit einem Windhauch kannst du das Feuer loeschen. Mit einem Windhauch kannst du das Feuer entfachen.
Mit einem Windhauch kannst du das Feuer loeschen. Mit einem Windhauch kannst du das Feuer entfachen.