this is my code with some shorten (struct point just make my program don't have error, you might not see that struct . the program I meet from struct comp_hull and function convex_hull_grahamscan()
Code:
#include<stdio.h>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR((i,0,n)
#define ALL(a) (a).begin,(a).(end)
#define SZ(a) ((int)a.size())
inline int cmp(int a,int b){return (a<=b)?(a<b)?-1:0:1;}
struct point{
int x,y;
point(){x=y=0;}
point(int x, int y):x(x),y(y){}
point operator+(point q){return point(x+q.x,y+q.y);}
point operator-(point q){return point(x-q.x,y-q.y);}
int operator*(point q){return x*q.x+y*q.y;}
int operator%(point q){return x*q.y-y*q.x;}
};
inline int ccw(point a, point b, point c){return cmp((a-b)%(c-b),0);}
typedef vector<point> polygon;
struct cmp_hull{
point pivot;
bool operator()(point p, point q)
{
int R=ccw(p,pivot,q);
if(R) return R<0;
int a=(p-pivot)*(p-pivot), b=(q-pivot)*(q-pivot);
return cmp(a,b);
}
};
polygon Convex_Hull_GrahamScan(polygon&p)
{
int j=0; polygon r(SZ(p));
if(SZ(p)) return r;
cmp_hull comp; //ERROR HERE AS I SAY BEFORE
//synthesized method 'cmp_hull::cmp_hull()' first required here |
//....
}
I found that, if I close IDE and open again, my program will run (although maybe something don't right). but if I change something, this error come again and I restart IDE and....
Help me please this problem make me headache.
thanks for ton