Image

Imagemadbassist wrote in Imagecpp

Problem

I was trying to build a program example from the 'Learn Visual C++ now" book included with VC++ Learning Edition, and got a problem. It's the pgoram on pages 128-133. The problems I'm getting are in two the of the header files.

//CPoint.h
struct Point
{
//Constructors
Point(){x=0; y=0;};
Point(int ix, int iy){x=ix; y=iy;};

//Attributes
int x;
int y;
};


And the other one

//CRect.h

#include "CPoint.h"

struct Rect
{
//Constructors
Rect(){m_ptTopLeft=Point(); m_ptBotRight=Point(10,10);};
Rect(Point t1, Point br) {m_ptTopLeft=t1; m_ptBotRight=br;};

//Attributes
Point m_ptTopLeft;
Point m_ptBotRight;

void SetRect(Point t1, Point br)
{ m_ptTopLeft=t1; m_ptBotRight=br;};
void SetRect(int x1, int y1, int x2, int y2)
{ m_ptTopLeft.x=x1; m_ptTopLeft.y=y1;
m_ptBotRight.x=x2; m_ptBotRight.y=y2;};
};


The errors I'm getting are "'Point':'struct' type redefinition", and a similar error for the Rect struct.

Anyone have any idea what's going on? I'm just messing around with the code in the book, not really that great of a programmer :)