// struct (used to group related data)
struct Point {
int x;
int y;
};
struct Point p1 = {0, 0};
p1.x = 3;
p1.y = 4;
// union (only one member can be accessed at a time)
union Data {
int i;
float f;
};
union Data data;
// note that accessing `i` after assigned `f` is undefined behavior.
data.i = 10; // only `i` is accessible now
data.f = 220.5; // only `f` is accessible now
// enum (used to define a set of named integer constants)
enum Color { RED, GREEN, BLUE };
enum Color c = BLUE;
if (c == RED) { /* ... */ }