struct bbox {
float x, y, w, h;
//重载==运算符,相等返回1,不等返回0
bool operator==(const bbox &p) {
return (x==p.x && y==p.y && w==p.w && h==p.h);
}
};
int main(int argc, char const *argv[]) {
bbox a = {.x=0.1, .y=0.2, .w=.3, .h=.4};
//结构体深拷贝
bbox b = a;
a.x = -1;
if (a==b) cout << "equal" << endl;
return 0;
}