Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- class CPoint
- {
- protected:
- int x;
- int y;
- public:
- CPoint()
- {
- x = 0;
- y = 0;
- };
- CPoint(int _x, int _y)
- {
- x = _x;
- y = _y;
- }
- friend istream& operator>> (istream &in, CPoint &cpoint);
- friend ostream& operator<< (ostream &out, CPoint &cpoint);
- void get_out_XY()
- {
- cout << "Значение координаты x: " << x << ' ' << "Значение координаты y: " << y << endl;
- }
- int get_X()
- {
- return x;
- }
- int get_Y()
- {
- return y;
- }
- void set_XY(int _x_, int _y_)
- {
- x = _x_;
- y = _y_;
- }
- void get_XY(int &x, int &y)
- {
- x = this->x;
- y = this->y;
- }
- };
- istream& operator>> (istream &in, CPoint &cpoint)
- {
- cout << "Введите координаты x и y: ";
- in >> cpoint.x >> cpoint.y;
- return in;
- }
- ostream& operator<< (ostream &out, CPoint &cpoint)
- {
- cout << "Координаты х и у: ";
- out << cpoint.x << ' ' << cpoint.y << endl;
- return out;
- }
- class CLine : public CPoint
- {
- private:
- int length = 0;
- CPoint *mas;
- public:
- CLine(CPoint *massive,int num)
- {
- length = num;
- *mas = *new CPoint[length];
- for(int i =0 ;i < num; i++)
- {
- mas[i]=massive[i];
- }
- }
- void get_info()
- {
- for(int i = 0; i < length; i++)
- {
- mas[i].get_out_XY();
- }
- }
- void add(CPoint &p)
- {
- length++;
- mas[length-1] = p;
- }
- };
- ////////////
- class CcoloredPoint : public CPoint
- {
- private:
- vector <char> v;
- public:
- CcoloredPoint():CPoint(){};
- CcoloredPoint(int _x, int _y, vector <char> new_v):CPoint(_x,_y)
- {
- v = new_v;
- }
- friend ostream& operator<< (ostream &out, CPoint &cpoint);
- vector <char> Get_v () {
- return v;
- }
- };
- ostream& operator<< (ostream &out, CcoloredPoint &cpoint)
- {
- cout << "Координаты х и у: ";
- out << cpoint.get_X() << ' ' << cpoint.get_Y() << endl;
- cout << "Цвет " << endl;
- vector <char> ws_v = cpoint.Get_v();
- for (auto i : ws_v) {
- out << i;
- }
- return out;
- }
- class CcoloredLine : public CcoloredPoint{
- private :
- vector <CcoloredPoint> v;
- public :
- CcoloredLine (vector <CcoloredPoint> new_v) {
- for (auto i : new_v) {
- v.push_back(i);
- }
- }
- void get_info()
- {
- for (auto i : v) {
- cout << i << endl;
- }
- }
- };
- int main()
- {
- // CPoint first;
- // int absc, ord;
- // cin >> absc >> ord;
- // first.set_XY(absc, ord);
- // cout << first;
- int a = 5, b = 7;
- char test [] = { 'w', 'h', 'i', 't', 'e' };
- vector<char> v;
- for(int i=0;i<5;i++)
- v.push_back(test[i]);
- CcoloredPoint first (a, b, v);
- cout << first << endl;
- /*CPoint f(2,5), d(3, 6);
- CPoint *massive_pointov= new CPoint[2];
- massive_pointov[0]=f;
- massive_pointov[1]=d;
- CLine fr(massive_pointov,2);
- fr.get_info();
- cout<<endl;
- fr.add(f);
- fr.get_info();*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement