C++结构体重构

#include<cstdio>
using namespace std;
struct node
{
	int x,y;
	node() {x=0,y=0;}// 赋初值
	bool operator > (node &a) {return x.x>x;}//重构运算符
}a,b;
int main()
{
	a=(node){3,3};b=(node){4,2};
	if (a>b) b=a;
	printf("%d %d
",b.x,b.y);
	return 0;
}

希望能对你有用!

转载需注明出处。
原文地址:https://www.cnblogs.com/jz929/p/11817770.html