Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. typedef enum
  2. {
  3. ShapeType_RECT,
  4. ShapeType_CIRCLE
  5. } ShapeType;
  6.  
  7. typedef struct
  8. {
  9. ShapeType type;
  10. union
  11. {
  12. Rect rect;
  13. int radius;
  14. };
  15.  
  16. Color color;
  17. // etc
  18. } Shape;
  19.  
  20. // So, the usual way of doing dynamic types in C: Enum describing which type it is, a union of the various type-specific values, also values common to both like color.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement