daily pastebin goal
34%
SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Dana {
  5.   protected:
  6.     int bok, kat;
  7.   public:
  8.     Dana(){
  9.        cout<<"Podaj dlugosci " << endl;
  10.     };
  11.  
  12.     void is_valid(int a, int b){
  13.       if(a<0 || b<0 || b>360){
  14.         cout <<"Bledne dane"<<endl;
  15.         bok = 0;
  16.         kat = 0;
  17.       }
  18.     }
  19.  
  20.     void set_values (int a, int b){
  21.         bok=a;
  22.         kat=b;
  23.         is_valid(a,b);
  24.      }
  25.  
  26. };
  27.  
  28. class Dlugosc: public Dana {
  29.   public:
  30.     int get()
  31.       { return bok; }
  32. };
  33.  
  34. class Kat: public Dana {
  35.   public:
  36.     int get()
  37.       { return kat; }
  38. };
  39.  
  40. int main () {
  41.   int a,b;
  42.   Dlugosc dl;
  43.   cin>>a;
  44.   Kat kt;
  45.   cin>>b;
  46.   Dana * dlBoku = &dl;
  47.   Dana * katt = &kt;
  48.   dlBoku->set_values (a,b);
  49.   katt->set_values (a,b);
  50.   cout << "Dlugosc boku: "<<dl.get() << '\n';
  51.   cout << "Kat: "<<kt.get() << '\n';
  52.   return 0;
  53. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top