Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. class Punkt
  6. {
  7. //protected:
  8.  
  9. float x, y;
  10.  
  11. public:
  12.  
  13. Punkt(float xx=0, float yy=0)
  14. {
  15. x=xx;
  16. y=yy;
  17. }
  18. void Wyslietl()
  19. {
  20. cout<<x<<endl<<y<<endl;
  21. }
  22. };
  23.  
  24. class Kolo:public Punkt
  25. {
  26. protected:
  27.  
  28. int r;
  29. int p;
  30.  
  31. public:
  32. Kolo(float xx=0, float yy=0, float rr=1)
  33. :Punkt(xx, yy)
  34. {
  35. //x=xx;
  36. //y=yy;
  37. r=rr;
  38. p=M_PI*r*r;
  39. }
  40. float pole()
  41. {
  42. int p;
  43. p=M_PI*r*r;
  44. return p;
  45. }
  46. void Wyslietl()
  47. {
  48. Punkt::Wyslietl();
  49. cout<<r<<endl;
  50. cout<<p<<endl;
  51. }
  52. };
  53.  
  54. class Kula: public Kolo
  55. {
  56. //int p;
  57. float v;
  58. public:
  59. Kula(float xx=0, float yy=0, float rr=1)
  60. :Kolo(xx, yy, rr)
  61. {
  62. //x=xx;
  63. //y=yy;
  64. //r=rr;
  65. p=4*M_PI*r*r;
  66. v=(4/3)*M_PI*r*r*r;
  67. }
  68. /*float pole()
  69. {
  70. int p;
  71. p=4*M_PI*M_PI;
  72. return p;
  73. }*/
  74. void Wyslietl()
  75. {
  76. Kolo::Wyslietl();
  77. cout<<v;
  78. }
  79. };
  80.  
  81. int main()
  82. {
  83. /*cout << "Hello world!" << endl;
  84. Punkt p1;
  85. p1.Wyslietl();
  86. Kolo k1;
  87. cout<<k1.pole()<<endl;
  88. k1.Wyslietl();*/
  89. Kula k2(float=1, float=2, float=3);
  90. k2.Wyslietl();
  91. return 0;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement