Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct date
- {
- unsigned day;
- struct date *(*func[2])(struct date*);
- };
- struct date *create_date(void)
- {
- struct date *obj = malloc(sizeof(struct date));
- return obj ? obj : NULL;
- }
- struct date *assign(struct date *this, unsigned value){
- this->day = value;
- return this;
- }
- struct date* print(struct date *this){
- printf("%dn",this->day);
- return this;
- }
- int main()
- {
- struct date *my = create_date();
- assign(my,13);
- my->func[0] = print;
- my->func[1] = print;
- my->func[0](my)->func[1](my);
- //print(my);
- free(my);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement