Advertisement
programusy

Untitled

Mar 23rd, 2023
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class figura
  6. {
  7. public:
  8. string nazwa;
  9.  
  10. double pole();
  11. double obwod();
  12.  
  13.  
  14. };
  15.  
  16. double figura::pole()
  17. {
  18. cout << "Pole figury " << endl;
  19. return 0;
  20. }
  21.  
  22. double figura::obwod()
  23. {
  24. cout << "Obwod figury " << endl;
  25. return 0;
  26. }
  27.  
  28. class prostokat : public figura
  29. {
  30. public:
  31. double podstawa;
  32. double wysokosc;
  33.  
  34. double pole();
  35. double obwod();
  36. };
  37.  
  38. double prostokat::pole()
  39. {
  40. double pole_p;
  41.  
  42. cout << "Pole prostokata: ";
  43.  
  44. pole_p = podstawa * wysokosc;
  45.  
  46. return pole_p;
  47. }
  48.  
  49. double prostokat::obwod()
  50. {
  51. double obwod_p;
  52.  
  53. cout << "Obwod prostokata: ";
  54.  
  55. obwod_p = 2*(podstawa + wysokosc);
  56.  
  57. return obwod_p;
  58. }
  59.  
  60. int main()
  61. {
  62. figura f;
  63.  
  64. f.pole();
  65. f.obwod();
  66.  
  67. prostokat p;
  68.  
  69. p.podstawa = 10;
  70. p.wysokosc = 5;
  71.  
  72. cout << p.pole() << endl;
  73. cout << p.obwod() << endl;
  74.  
  75. cout << "Hello world!" << endl;
  76. return 0;
  77. }
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement