Advertisement
rex897

мсчмчсмчсмсчмчмчсмсчмсчмч

Jan 15th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.24 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4. #include <fstream>
  5. #include <clocale>
  6. #include <curses.h>
  7. #include <cstdlib>
  8. #include <cstdio>
  9.  
  10. using namespace std;
  11. class dpoint
  12. {
  13.   private:
  14.     double *px;
  15.     double *py;
  16.  
  17.   public:
  18.     dpoint() // конструктор без параметров
  19.     {
  20.         px = new double(0);
  21.         py = new double(0);
  22.     }
  23.     ~dpoint()
  24.     {
  25.         if (px != NULL)
  26.             delete px;
  27.         if (py != NULL)
  28.             delete py;
  29.     }
  30.     dpoint(dpoint &z) //конструктор копирования
  31.     {
  32.         px = new double(*z.px);
  33.         py = new double(*z.py);
  34.     }
  35.     dpoint(double x0, double y0) //конструктор с параметрами
  36.     {
  37.         px = new double(x0);
  38.         py = new double(y0);
  39.     }
  40.     void input();
  41.     void output();
  42.     friend istream &operator>>(istream &in, dpoint &z);
  43.     dpoint &operator=(dpoint &z) //перегрузка присваивания
  44.     {
  45.         if (this == &z)
  46.             return z;
  47.         *px = *z.px;
  48.         *py = *z.py;
  49.         return *this;
  50.     }
  51. };
  52.  
  53. void dpoint::input()
  54. {
  55.     cout << "x = ";
  56.     cin >> *px;
  57.     cout << "y = ";
  58.     cin >> *py;
  59. }
  60. istream &operator>>(istream &in, dpoint &z)
  61. {
  62.     cout << "x = ";
  63.     in >> *z.px;
  64.     cout << "y = ";
  65.     in >> *z.py;
  66.     return in;
  67. }
  68. void dpoint::output()
  69. {
  70.     cout << "x = " << *px << endl;
  71.     cout << "y = " << *py << endl;
  72. }
  73.  
  74. class treug : public dpoint
  75. {
  76.   private:
  77.     dpoint *pa;
  78.     dpoint *pb;
  79.     dpoint c;
  80.  
  81.   public:
  82.     treug()
  83.     {
  84.         pa = new dpoint(0, 0);
  85.         pb = new dpoint(0, 0);
  86.     }
  87.     treug(double x1, double y1, double x2, double y2, double x3, double y3) : c(x3, y3)
  88.     {
  89.         pa = new dpoint(x1, y1);
  90.         pb = new dpoint(x2, y2);
  91.     }
  92.     ~treug()
  93.     {
  94.         if (pa != NULL) delete pa;
  95.         if (pb != NULL) delete pb;
  96.     }
  97.     treug(treug &z)
  98.     {
  99.         pa = new dpoint(*z.pa);
  100.         pb = new dpoint(*z.pb);
  101.         c = z.c;
  102.     }
  103.     treug& operator=(treug &z)
  104.     {
  105.         if (this == &z) return z;
  106.         *pa = *z.pa;
  107.         *pb = *z.pb;
  108.         c = z.c;
  109.     }
  110.     void output()
  111.     {
  112.         pa->output();
  113.         pb->output();
  114.         c.output();
  115.     }
  116.     friend void nev();
  117. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement