0

How can I cast a class to another type? Example:

class Point
{
    Point(int X, int Y);
};

Point A(10, 10);
POINT P = (POINT)A;
A = (Point)P;


//I've tried:

Point::Point(POINT P) : X(P.x), Y(P.y), Color(0) {} //Constructor.

Point& Point::operator ()(POINT P)
{
    if (X != P.x && Y != P.y)
    {
        X = P.x;
        Y = P.y;
        Color = 0;
    }
    return *this;
}

How do I go the other way around? I've tried doing the reverse the exact same way but it doesn't work. Did I do the above correctly?

Edited by triumphost

2
Contributors
1
Reply
3
Views
4 Years
Discussion Span
Last Post by firstPerson
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.