SHARE
TWEET

Untitled

a guest Dec 3rd, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  Klases - "inline" tipo funkcijos klases viduje
  3.  Autorius Vardenis Pavardenis, grupe XX
  4. */
  5. #include <iostream>
  6. using namespace std;
  7. //Klases "Box" deklaravimas
  8. class Box {
  9. public:
  10.     double ilgis;
  11.     double plotis;
  12.     double aukstis;
  13.  
  14.     //konstruktorius
  15.     Box(double i = 2.0, double p = 2.0, double a = 2.0)
  16.     {
  17.         cout << "Kvieciamas konstruktorius" << endl;
  18.         ilgis = i;
  19.         plotis = p;
  20.         aukstis = a;
  21.     }
  22.     //"inline" tipo funkcija - narys
  23.     double turis()
  24.     {
  25.         return ilgis * plotis * aukstis;
  26.     }
  27. };
  28. int main()
  29. {
  30.     Box deze; //sukuriamas objektas su nustatytaisiais parametrais
  31.     Box deze1(1.5, 2.5, 4.5); //sukuriamas 1 objektas
  32.     Box deze2(1.2, 3.1, 4.1); //sukuriamas 2 objektas
  33.     cout << endl;
  34.     cout << "dezes parametrai" << endl;
  35.     cout << "ilgis: " << deze.ilgis << endl;
  36.     cout << "plotis: " << deze.plotis << endl;
  37.     cout << "aukstis: " << deze.aukstis << endl;
  38.     cout << "turis: " << deze.turis() << endl;
  39.     cout << endl;
  40.     cout << "1 dezes parametrai" << endl;
  41.     cout << "ilgis: " << deze1.ilgis << endl;
  42.     cout << "plotis: " << deze1.plotis << endl;
  43.     cout << "aukstis: " << deze1.aukstis << endl;
  44.     cout << "turis: " << deze1.turis() << endl;
  45.     cout << endl;
  46.     cout << "2 dezes parametrai" << endl;
  47.     cout << "ilgis: " << deze2.ilgis << endl;
  48.     cout << "plotis: " << deze2.plotis << endl;
  49.     cout << "aukstis: " << deze2.aukstis << endl;
  50.     cout << "turis: " << deze2.turis() << endl;
  51.     cout << endl;
  52.     if (deze1.turis() > deze2.turis())
  53.         cout << "deze1 didesne uz deze2" << endl;
  54.     else
  55.         cout << "deze2 didesne arba lygi dezei1" << endl;
  56.     cout << endl;
  57.     system("pause");
  58.     return 0;
  59. }
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