Advertisement
endreweast

Practic 1.1

Dec 16th, 2015
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class int1
  6. {
  7. private:
  8.         int nomer;
  9. public:
  10.         int1()
  11.         {
  12.                 init();
  13.         }
  14.         int1(int nom)
  15.         {
  16.                 nomer = nom;
  17.         }
  18.         void setNom(int nom)
  19.         {
  20.                 nomer = nom;
  21.         }
  22.         int getNom()
  23.         {
  24.                 return nomer;
  25.         }
  26.         void init()
  27.         {
  28.                 nomer = 0;
  29.         }
  30.         int1 operator+(int1 value)
  31.         {
  32.                 int1 result(nomer + value.getNom());
  33.                 return result;
  34.         }
  35.         void print()
  36.         {
  37.                 cout << "Nomber: " << nomer << endl;
  38.         }
  39. };
  40.  
  41. int main()
  42. {
  43.         int1 obj(10);
  44.         int1 obj1(25);
  45.         int1 result = obj + obj1;
  46.         result.print();
  47.         system("pause");
  48.         return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement