[C++] 纯文本查看 复制代码
#include <iostream>
using namespace std;
class three_d {
public:
int x, y, z;
three_d() { x = y = z = 0; };
three_d (int i, int j, int k) { x = i; y = j; z = k; }
bool operator==(three_d op2);
};
bool three_d::operator==(three_d op2)
{
if ((x == op2.x) && (y == op2.y) && (z == op2.z))
return true;
else
return false;
}
int main()
{
three_d a(1, 2, 3), b(5, 6, 9), c(5, 6, 9);
if (a == b)
cout << "a is equal to b\n";
else
cout << "a is not equal to b\n";
if (b == c)
cout << "b is equal to c\n";
else
cout << "b is not equal to c\n";
return 0;
}