C++ segment line intersection
<p>i would like to ask where is the problem?<br/><br/>
I got an <strong>error: invalid type argument of ‘unary *’</strong>  </p>

<p>I am new in c++ programming, i use java style.
Pointer and dereference is a big problem for me.</p>

<p>My application got input values and save as point object, after this i should find intersection of 2 lines. </p>

<p>I thought to return a Point object in which i will compute x and y value.</p>

<p>.h file</p>

<pre><code>class Point {
public:
    double x_val, y_val;

    Point(double, double);

    double x();
    double y();

    double dist(Point other);

    Point add(Point b);
    Point sub(Point b);

    void move(double a, double b);



};



 class Triungle {
public:


        Triungle(std::string);
        void compute_length();
        void lines_intersect(Point a, Point b, Point c, Point d, Point *intersection);

        Point a, b, c;
};
</code></pre>

<p>.cpp file</p>

<pre><code>Point::Point(double x = 0.0, double y = 0.0) {
    x_val = x;
    y_val = y;
}

double Point::x() {
    return x_val;
}

double Point::y() {
    return y_val;
}

double Point::dist(Point other) {
    double xd = this-&gt;x() - other.x();
    double yd = this-&gt;y() - other.y();
    return sqrt(xd * xd + yd * yd);
}

Point Point::add(Point b) {
    return Point(x_val + b.x_val, y_val + b.y_val);
}

Point Point::sub(Point b) {
    return Point(x_val - b.x_val, y_val - b.y_val);
}

void Point::move(double a, double b) {
    x_val += a;
    y_val += b;
}

    void Triungle::lines_intersect(Point a, Point b, Point c, Point d, Point *intersection) {

        double x, y;
        double A1 = b.y_val - a.y_val;
        double B1 = b.x_val - a.x_val;
        double C1 = a.y_val - (A1 / B1) * a.x_val;

        double A2 = d.y_val - c.y_val;
        double B2 = d.x_val - c.x_val;
        double C2 = c.y_val - (A2 / B2) * c.x_val;

        double det = (A1 / B1) - (A2 / B2);
        if (det == 0) {
            // lines are paralel
        } else {
            x = (C2 - C1) / det;
            y = (A1 * C2 - A2 * C1) / det;
        }
        *intersection-&gt;x_val = x;  // here i got error
        *intersection-&gt;y_val = y;  // here i got error
       }

Triungle::Triungle(std::string s) {

    cout &lt;&lt; "enter first point of " &lt;&lt; s &lt;&lt; " triangle: ";
    cin &gt;&gt; a.x_val;
    cin &gt;&gt; a.y_val;
    if (!(cin)) {
        cout &lt;&lt; "input error." &lt;&lt; endl;
        exit(1);
    }
    cin.clear();
    cout &lt;&lt; "enter second point of " &lt;&lt; s &lt;&lt; " triangle: ";
    cin &gt;&gt; b.x_val;
    cin &gt;&gt; b.y_val;
    if (!(cin)) {
        cout &lt;&lt; "input error." &lt;&lt; endl;
        exit(1);
    }
    cin.clear();
    cout &lt;&lt; "enter 3 point of " &lt;&lt; s &lt;&lt; " triangle: ";
    cin &gt;&gt; c.x_val;
    cin &gt;&gt; c.y_val;
    if (!cin) {
        cout &lt;&lt; "input error." &lt;&lt; endl;
        exit(1);
    }
    cin.clear();

}
</code></pre>

<p>and i call function in this way</p>

<pre><code> int main(int argc, char** argv) {
    Triungle a("first");
    Triungle b("second");
 Point p;

    a.lines_intersect(a.a, a.b, a.c, a.a, &amp;p);

}
</code></pre>
