fork download
  1. #include <iostream>
  2.  
  3. class airship
  4. {
  5. public:
  6. unsigned int nPerson;
  7. unsigned int nWeight;
  8. void Show()
  9. {
  10. printf("person: %d, weight: %d\n", nPerson, nWeight);
  11. }
  12. };
  13.  
  14. class airplane : airship
  15. {
  16. public:
  17. bool bPropeller;
  18. float nDistance;
  19. void Show()
  20. {
  21. printf("person: %d, weight: %d, type: %s, distance: %f\n", nPerson, nWeight, bPropeller ? "Propeller" : "Jet", nDistance);
  22. }
  23. };
  24.  
  25. class baloon : airship
  26. {
  27. public:
  28. unsigned int bHydrogen;
  29. unsigned int nMaxAltitude;
  30. void Show()
  31. {
  32. printf("person: %d, weight: %d, fuel: %s, max-altitude: %d\n", nPerson, nWeight, bHydrogen ? "Hydrogen" : "Helium", nMaxAltitude);
  33. }
  34. };
  35.  
  36. int main()
  37. {
  38. airship s = airship();
  39. airplane p = airplane();
  40. baloon b = baloon();
  41. s.Show();
  42. p.Show();
  43. b.Show();
  44. return 0;
  45. }
  46.  
Success #stdin #stdout 0.02s 2724KB
stdin
Standard input is empty
stdout
person: 0, weight: 0
person: 0, weight: 0, type: Jet, distance: 0.000000
person: 0, weight: 0, fuel: Helium, max-altitude: 0