Created
May 14, 2011 13:32
-
-
Save cocoatomo/972214 to your computer and use it in GitHub Desktop.
PyObject の基礎: ソースコード2
This file contains 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
#include <stdio.h> | |
#include <stdlib.h> | |
struct base { | |
int basic_field; | |
}; | |
struct extended { | |
struct base base; | |
int extended_field; | |
}; | |
int main(void) | |
{ | |
struct base *base_obj; | |
struct extended *obj = malloc(sizeof(struct extended)); | |
obj->base.basic_field = 1; | |
obj->extended_field = 2; | |
base_obj = (struct base *) obj; | |
printf("base_obj->basic_field: %d\n", base_obj->basic_field); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment