Hi
I have a couple of classes defined, one class and structures defined that are from another class. So I have for example:
and Point is thus defined:Code:class Edge { public: Point org; Point dest; Edge(Point &_org, Point &_dest); Edge(void); Edge &rot(void); Edge &flip(void); Point point(double); int intersect(Edge&, double&); int cross(Edge&, double&); bool isVertical(void); double slope(void); double y(double); };
In terms of construction, I have placed the class constructs in Point.h and Edge.h with the member functions in Point.cpp and Edge.cpp. I then have a file called Polygons.cpp which includes the header files. However when I try and make with the following makefile, I dont get anything:Code:class Point{ public: double x; double y; Point(double _x = 0.0, double _y = 0.0); Point operator+(Point&); Point operator-(Point&); friend Point operator*(double, Point&); double operator[](int); int operator==(Point&); int operator!=(Point&); int operator<(Point&); int operator>(Point&); int classify(Point&, Point&); int classify(Edge&); double polarAngle(void); double length(void); double distance(Edge&); };
I find the following errors:Code:all: Poly Poly: Point.o Edge.o Polygons.o g++ -O4 -o Poly Point.o Edge.o Polygons.o Point.o: Point.cpp g++ -O4 -c -Wno-deprecated -Wall Point.cpp -o Point.o Edge.o: Edge.cpp g++ -O4 -c -Wno-deprecated -Wall Edge.cpp -o Edge.o Polygons.o: Polygons.cpp g++ -O4 -c -Wno-deprecated -Wall Polygons.cpp -o Polygons.o clean: find . -name '*.o' | xargs rm -f ;
Edge.h:8: error: ‘Point’ does not name a type
Edge.h:9: error: ‘Point’ does not name a type
Edge.h:10: error: expected `)' before ‘&’ token
Edge.h:14: error: ‘Point’ does not name a type
BTW, a typical .h function looks like this:
How should I best construct these sort of classes???Code:#ifndef _Edge_h #define _Edge_h #include "Point.h" class Edge { public: Point org; Point dest; Edge(Point &_org, Point &_dest); Edge(void); Edge &rot(void); Edge &flip(void); Point point(double); int intersect(Edge&, double&); int cross(Edge&, double&); bool isVertical(void); double slope(void); double y(double); }; // Edge::Edge(Point &_org, Point &_dest) : // org(_org), dest(_dest) // { // // } // // Edge::Edge(void) : // org(Point(0,0)), org(Point(1,0)) // { // // } // // Edge &Edge::rot(void) // { // Point m = 0.5 * (org + dest); // Point v = dest - org; // Point n(n.y, -v.x); // org = m - 0.5 *n; // dest = m + 0.5 *n; // return *this; // } // // Edge &Edge::flip(void) // { // return rot().rot(); // } // // Point Edge::point(double t) // { // return Point(org + t * (dest - org)); // } // // enum { COLLINEAR, PARALLEL, SKEW, SKEW_CROSS, SKEW_NO_CROSS}; // // double dotProduct(Point &p, Point &q) // { // return (p.x * q.x + p.y *q.y); // } // // int Edge::intersect(Edge &e, double &t) // { // Point a = org; // Point b = dest; // Point c = e.org; // Point d = e.dest; // Point n = Point((d-c).y, (c-d).x); // double denom = dotProduct(n, b-a); // if (denom == 0.0) // { // int aclass = org.classify(e); // if ((aclass==LEFT) || (aclass==RIGHT)) // return PARALLEL; // else // return COLLINEAR; // } // double num = dotProduct(n, a-c); // t=-num/denom; // return SKEW; // } #endif
Thanks



LinkBack URL
About LinkBacks




rg. Point:
oint(double)’: