开发时需要判断结构体是否相等,可以通过重载==运算符来实现。
举个例子:
struct Point
{
double x;
double y;
double z;
//==运算符重载
bool operator==(const Point &p)
{
return(x=p.x && y=p.y && z=p.z);
}
};
开发时需要判断结构体是否相等,可以通过重载==运算符来实现。
举个例子:
struct Point
{
double x;
double y;
double z;
//==运算符重载
bool operator==(const Point &p)
{
return(x=p.x && y=p.y && z=p.z);
}
};