Object not being constructed properly

I am having an issue with objects in my program not being constructed properly. I have a feeling it has something to do with the POINT structure. Anyhow, here are the class definition for my objects. Currently there is an abstract class Shape, and a derived class Rect.

Shape:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Shape
{
protected:
	HDC hdc;
	POINT pointA, pointB, pointC;
	HRGN shapeRgn;
	RECT shapeRect;
	float b,h;
	int idShape;
public:
	Shape(HDC dc, POINT a, POINT b, POINT c, int i) :
	  hdc(dc), pointA(a), pointB(b), pointC(c), idShape(i)
	  {}
	Shape(HDC dc, POINT a, POINT b, int i) : 
	  hdc(dc), pointA(a), pointB(b), idShape(i)
	  {}
	~Shape()
	  {}
	int returnId() { return idShape; }
	void Erase();
	virtual float CalculateArea() = 0;
	virtual void Draw() = 0;
	virtual void SetShapeRgn() = 0;
	void SetShapeRect();
	bool TestSelect(POINT a);
};


Rect:
1
2
3
4
5
6
7
8
9
10
class Rect : public Shape
{
public:
	Rect(HDC hdc, POINT a, POINT b, int i) :
	  Shape(hdc,a,b,i)
	  {}
	void Draw();
	float CalculateArea();
	void SetShapeRgn();
};


An object is created during a WM_LBUTTONDOWN message. Here is the current implementation for the creation of the object. A user will click once at some point on the window, the program stores this point. The user clicks again at another point in the window, and the program stores this point as well. Now the program creates an object which is initialized with the device context, the points, and the index (current number) of shapes.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
		case RECTANGLE:
			if (click == 0)
			{
				GetCursorPos(&pa);
				ScreenToClient(renderWnd,&pa);

				click = 1;
			}
			else if (click == 1)
			{
				GetCursorPos(&pb);
				ScreenToClient(renderWnd,&pb);

				shapes = new Rect(hdc,pa,pb,shapeCount);
				shapes->Draw();
				shapes->SetShapeRect();
				shapes->SetShapeRgn();
				shapeCount++;

				click = 0;
			}
			break;

Note that "shapes" is a pointer to a Shape object.

Now when I debug the program, the local values for pa and pb are normal and make sense. However when I look at the values of pointA and pointB for the created object, they are incredibly large and nowhere near the values of pa and pb. Can someone tell me what is going wrong? Am I handling the POINT structures properly? Any help is greatly appreciated, and if you need any more pertinent information from my code, please don't hesitate to ask.
Not all the members are initialised. The base class destructor isn't virtual.

You have to get the basics right.
i realize that all the members are not initialized. will that affect the other members not being initialized properly?

I would appreciate it if you could help answer my question rather than point out other flaws in the program
Topic archived. No new replies allowed.