编写工具:devC++
测试环境:windows系统
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
struct Sun
{
int a;
string b;
bool operator==(const Sun sun1)
{
return (sun1.a==a && sun1.b==b);
};
};
int main()
{
struct Sun sun1,sun2;
sun1.a=1;
sun2.a=1;
sun1.b="sun";
sun2.b="sun";
if(sun1==sun2)
cout<< "sun1==sun2" << endl;
system("PAUSE");
return 0;
}