[c++]co tu niegra

0

Nie wiem dlaczego, ale w tym programie nie zmieniają mi się współrzędne. Co tu jest zle napisane??

#include <iostream.h>
class Point		// przechowuje wspolrzedne x,y
{
// bez konstruktora, uzywa domyslnego
public:
int x,y;
	void SetX(int x) { itsX = x; }
	void SetY(int y) { itsY = y; }
	int GetX()const { return itsX; }
	int GetY()const { return itsY; }
private:
	int itsX;
	int itsY;
};	// koniec deklaracji klasy Point

class Rectangle
{
public:
	Rectangle (int top, int left, int bottom, int right);
	~Rectangle () {}

	int GetTop()const { return itsTop; }
	int GetLeft()const { return itsLeft; }
	int GetBottom()const { return itsBottom; }
	int GetRight()const { return itsRight; }

	Point GetUpperLeft() const { return itsUpperLeft; }
	Point GetLowerLeft() const { return itsLowerLeft; }
	Point GetUpperRight() const { return itsUpperRight; }
	Point GetLowerRight() const { return itsLowerRight; }

	void SetUpperLeft (Point Location) { itsUpperLeft = Location; }
	void SetLowerLeft (Point Location) { itsLowerLeft = Location; }
	void SetUpperRight (Point Location) { itsLowerLeft = Location; }
	void SetLowerRight (Point Location) { itsLowerLeft = Location; }
	
	void SetTop (int top) { itsTop = top; }
	void SetLeft (int left) { itsLeft = left; }
	void SetBottom (int bottom) { itsBottom = bottom; }
        void SetRight (int right) { itsRight = right; }

	int GetArea() const;

	private:
		Point itsUpperLeft;
		Point itsUpperRight;
		Point itsLowerLeft;
		Point itsLowerRight;
		int itsTop;
		int itsLeft;
		int itsBottom;
		int itsRight;
	}
0

Witam
Myślę, że problem leży w klasie Point.
Brakuje Ci konstruktora kopiującego bądź operatora przypisania "operator=".
Jeśli zdecydujesz się na konstruktor kopiujący, to stwórz także normalny konstruktor, bo mogą być problemy.
Mam nadzieję, że pomoże.

0

w klasie TPoint nie masz zadnego konstruktora przez co zmienne wewnatrz klasy nie sa zainicjowane, a to z kolei oznacza ze maja wartosci losowe...

1 użytkowników online, w tym zalogowanych: 0, gości: 1