SOLVED:
My mistake was using the dot
instead of a =
so changing:
myRect.Rect(pt1,pt2,pt3,pt4); <-- didn't work
myRect = Rect(pt1,pt2,pt3,pt4); <-- worked
(thanks for the quick help! Even for getting a -1 for this question)
Initial QUESTION:
I tried to make my problem as simple as possible. I don't know why this doesn't work. How do I change the points of a created rect
? My guess is that I am not working correctly with the 'this ->
operator'.
I don't even know how to correctly title my question, any hints for better labeling?
point.h
class Point
{
private:
public:
int X;
int Y;
};
point.cpp
Point::Point() {
X = 0;
Y = 0;
}
rect.h
class Rect
{
private:
Point P1, P2, P3, P4;
public:
Rect();
Rect(Point p1, Point p2, Point p3, Point p4);
};
rect.cpp
Rect::Rect(Point p1, Point p2, Point p3, Point p4) {
this -> P1 = p1;
this -> P2 = p2;
this -> P3 = p3;
this -> P4 = p4;
}
main.cpp
int main(){
Rect myRect;
Point pt1;
Point pt2;
Point pt3;
Point pt4;
myRect.Rect(pt1,pt2,pt3,pt4);
}
ErrorMessage:
Invalid use of
'Rect::Rect'