Advertisement
Guest User

Nowy kod

a guest
Apr 25th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. class Czworokat
  4. {
  5. protected:
  6. double a,b,c,d;
  7. public:
  8. Czworokat()
  9. {
  10.  
  11. }
  12. Czworokat(double a, double b, double c, double d)
  13. {
  14. this->a=a;
  15. this->b=b;
  16. this->c=c;
  17. this->d=d;
  18. }
  19. void wypisz()
  20. {
  21. cout<<endl<<"Dlugosc boku a:"<<a;
  22. cout<<endl<<"Dlugosc boku b:"<<b;
  23. cout<<endl<<"Dlugosc boku c:"<<c;
  24. cout<<endl<<"Dlugosc boku d:"<<d;
  25.  
  26. }
  27. virtual double oblicz_pole();
  28. };
  29. class Prostokat: public Czworokat
  30. {
  31. public:
  32. Prostokat()
  33. {
  34.  
  35. }
  36. Prostokat(double a, double c)
  37. {
  38. this->a=a;
  39. this->b=a;
  40. this->c=c;
  41. this->d=c;
  42.  
  43. }
  44. double oblicz_pole()
  45. {
  46. return a*c;
  47.  
  48. }
  49. void wymiary(double a,double c)
  50. {
  51. this->a=a;
  52. this->b=a;
  53. this->c=c;
  54. this->d=c;
  55. }
  56.  
  57. };
  58. class Kwadrat: public Prostokat
  59. {
  60. public:
  61. Kwadrat()
  62. {
  63.  
  64. }
  65. Kwadrat(double a)
  66. {
  67. this->a=a;
  68. this->b=a;
  69. this->c=a;
  70. this->d=a;
  71.  
  72. }
  73. double oblicz_pole()
  74. {
  75. return a*a;
  76. }
  77. void wymiar(double a)
  78. {
  79. this->a=a;
  80. this->b=a;
  81. this->c=a;
  82. this->d=a;
  83.  
  84. }
  85.  
  86. };
  87. int main()
  88. {
  89. Czworokat *czworokat_1=new Czworokat(1,2,3,4);
  90. czworokat_1->wypisz();
  91. return 0;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement