I am working with computer graphics.
I would like to represent a line with two end points, and, then I would like my Line2d class to have a method that
There are many forms of line representation.
If you mean line (not segment), then, probably, you'll find convenient to use class/structure, containing BasePoint and UnitDirectionVector.
For line segments, choose between (Point pt0, Point pt1) form, and, (Point pt, Vector v = pt1 - pt0) form.
The second one is more suitable for parametric approach like,
X = P0.X + t * D.X etc.