Last active
September 17, 2018 20:55
-
-
Save flatcap/d3be59b0989f9a89d1b7a99d22c24923 to your computer and use it in GitHub Desktop.
inheritance
This file contains hidden or 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> | |
/* ---------------------------------- */ | |
#define struct_Named \ | |
char *name | |
struct Named | |
{ | |
struct_Named; | |
}; | |
/* ---------------------------------- */ | |
struct Account; | |
#define struct_Account \ | |
struct_Named; \ | |
struct Account *next | |
struct Account | |
{ | |
struct_Account; | |
}; | |
/* ---------------------------------- */ | |
struct ImapAccount | |
{ | |
struct_Account; | |
int i; | |
}; | |
struct PopAccount | |
{ | |
struct_Account; | |
int p; | |
}; | |
int main() | |
{ | |
struct ImapAccount ia; | |
ia.name = "imap"; | |
ia.next = NULL; | |
ia.i = 42; | |
struct PopAccount pa; | |
pa.name = "pop"; | |
pa.next = NULL; | |
pa.p = 99; | |
printf ("%s, %d\n", ia.name, ia.i); | |
printf ("%s, %d\n", pa.name, pa.p); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment