标签:pre 关系 ted 关系操作符 else min str name code
#include <iostream> using namespace std; class AAA { public: AAA() //默认构造 { } AAA(int id, string name) { this->id = id; this->name = name; } ~AAA()//析构 { } bool operator > (AAA& a)//重载关系操作符 { if (this->id > a.id) { return true; } else { return false; } } protected: //定义成员变量 int id; string name; }; int main() { AAA a(1, "xiaoming"); AAA b(2, "xiaogang"); if (a > b) { cout << "111\n"; } else { cout << "222\n"; } return 0; }
标签:pre 关系 ted 关系操作符 else min str name code
原文地址:https://www.cnblogs.com/shenji/p/12325224.html