我的学习记录46

来源:互联网 发布:大数据 adhoc 编辑:程序博客网 时间:2024/05/18 03:46

2017.11.25李锦浩【第46天】

今天继续学习了关于类的继承性,多继承和单继承的问题,我只是对此做了一个简单的了解。明天还要继续学习继承的问题。另外我今天还编写了一个类的程序,加强对类的运用与学习。

附:

#include<iostream>

#include<ctime>

using namespace std;

struct point

{

         int x;

         int y;

};

class line

{

public:

         line();

         ~line(){}

         void showlist();

         friend void setpoint(line&l1,line&l2);

private:

         int a;

         int b;

};

void line::showlist()

{

         cout << "y=" << a <<"x+" << b << endl;

}

void setpoint(line&l1,line&l2)

{

         point p;

         int x, y;

         x = (l1.b - l2.b);

         y = (l2.a - l1.b);

         p.x = x / y;

         p.y = l1.a*p.x + l1.b;

         cout << "x=" << p.x << endl;

         cout << "y=" << p.y << endl;

}

line::line()

{

         int xa[20];

         srand(time(0));

         for (int i = 0; i < 20; i++)

         {

                  xa[i] = rand() % 10;

         }

         srand(xa[20]);

         a = rand() % 10;

         b = rand() % 10;

}

int main()

{

         line l1;

         l1.showlist();

         line l2;

         l2.showlist();

         setpoint(l1, l2);

         system("pause");

         return 0;

}

明天任务:明天学习关于类的继承性,编写一个重载符号的程序。

原创粉丝点击