Advertisement
JakubKaczmarek

Untitled

Apr 28th, 2022
784
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Kalkulator
  6. {
  7.     protected:
  8.         float liczba1;
  9.         float liczba2;
  10.     public:
  11.         float dodaj_liczby();
  12.         Kalkulator();
  13.         Kalkulator(float nliczba1, float nliczba2);
  14. };
  15.  
  16. class SuperKal : public Kalkulator
  17. {
  18.     public:
  19.         SuperKal() {}
  20.         SuperKal(float nx, float ny);
  21.         float Superoper();
  22. };
  23.  
  24. float Kalkulator::dodaj_liczby()
  25. {
  26.     return liczba1+liczba2;
  27. }
  28.  
  29. Kalkulator::Kalkulator()
  30. {
  31.     liczba1=0.0;
  32.     liczba2=0.0;
  33. }
  34.  
  35. Kalkulator::Kalkulator(float nliczba1, float nliczba2)
  36. {
  37.     liczba1=nliczba1;
  38.     liczba2=nliczba2;
  39. }
  40.  
  41. SuperKal::SuperKal(float nx, float ny) : Kalkulator(nx, ny){
  42. }
  43.  
  44. float SuperKal::Superoper()
  45. {
  46.     return liczba1*liczba2;
  47. }
  48.  
  49. int main()
  50. {
  51.     Kalkulator k1(5.4,8.2);
  52.     cout << k1.dodaj_liczby() << endl;
  53.     SuperKal SK1(5.5,7.7);
  54.     cout << SK1.Superoper() << endl;
  55.     cout << SK1.dodaj_liczby() << endl;
  56.     return 0;
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement