结构体重载:
重载一:
struct node
{
int value;
friend bool operator < (node a,node b)
{
return a.value<b.value;
}
};
重载二:
struct node
{
int value;
bool operator < (const node &n) const
{
return n.value<value;
}
};
优先队列:
priority_queue<int,vector<int>,greater<int> >q;//最小优先
priority_queue<int,vector<int>,less<int> >q1;//最大优先
等于号重载
const int len=2;
struct node
{
int a,b,arr[len];
int *c;
char s[100];
string str;
void operator=(const node& x)
{
a=x.a;
b=x.b;
c = (int*)malloc(sizeof(int) * 128);
c = x.c;
strcpy(s,x.s);
str=x.str;
for (int i=0;i<len;i++)
arr[i]=x.arr[i];
}
}