Guest User

Untitled

a guest
Oct 17th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. struct physical_t {
  5.  
  6. int mass;
  7. int radius;
  8. };
  9.  
  10. struct solarBody_t : physical_t {
  11.  
  12. float atmosphereDrag;
  13. unsigned int atmosphereHeight;
  14. };
  15.  
  16. struct ship_t : physical_t {
  17.  
  18. float engine;
  19. unsigned int engineRadius;
  20. };
  21.  
  22. union entity_t {
  23.  
  24. physical_t physical;
  25. solarBody_t solarBody;
  26. ship_t ship;
  27. };
  28.  
  29. vector <entity_t*> entity;
  30.  
  31. int main () {
  32.  
  33. entity.push_back (new entity_t);
  34. entity[0]->mass = 43;
  35. entity[0]->engine = 16;
  36. std::cout << entity[0]->mass << endl << entity[0]->engine << endl;
  37.  
  38. return 0;
  39. };
  40.  
  41. /*this should output
  42. 43
  43. 16
  44. */
Add Comment
Please, Sign In to add comment