Skip to content

Instantly share code, notes, and snippets.

@theQuazz
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save theQuazz/c2eda7fdd365b272defd to your computer and use it in GitHub Desktop.

Select an option

Save theQuazz/c2eda7fdd365b272defd to your computer and use it in GitHub Desktop.
crazy unions
enum student_t {
STUDENT,
GRADED_STUDENT
};
struct Student {
char *name;
};
struct GradedStudent {
struct Student student;
int grade;
};
struct DynamicStudent {
enum student_t student_type;
union {
Student student;
GradedStudent graded_student;
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment