Mail Archives: djgpp/1997/02/17/17:51:18
Here's my problem...
(please don't comment on my programming form, I know it needs work)
typedef class vertex
{
friend lindef;
friend seg;
private:
int x;
int y;
public:
vertex();
vertex(int xp, int yp);
vertex(vertex *the_vert);
trans_vertex(int trans_x, int trans_y);
set_x(int new_x) { x = new_x; }
set_y(int new_y) { y = new_y; }
get_x() { return x; }
get_y() { return y; }
}
typedef class lindef
{
friend seg;
private:
vertex start, end;
public:
lindef();
lindef(vertex *startv, vertex *endv);
int get_sx() { return start.x; };
int get_sy() { return start.y; };
int get_ex() { return end.x; };
int get_ey() { return end.y; };
set_lindef(vertex *startv, vertex *endv)
{
start.x = startv->x;
start.y = startv->y;
end.x = endv->x;
end.y = endv->y;
}
};
As you can see, these two classes are friends of each other.
This means that each has a reference to the other within its
definition. Before lindef will mean anything to the compiler,
the class has to be defined. So I put lindef in front of vertex.
Now, of course, when the compiler gets to vertex, lindef means
nothing, so I get an error. If I switch them, the same thing will
happen.
What can I do?
Can you make the compiler do more than one pass?
HELP?
TIA
-Fwec
- Raw text -