标签:space 简单的 person cout 判断 tor end pre false
例1,最简单的情况,重载==,以判断两个对象是否相等
#include "stdafx.h" #include <iostream> using namespace std; class person { private: long id; public: person(long id) { this->id = id; } bool operator == (const person& person) const { if (this->id == person.id) return true; return false; } }; int main_20180715_0216() { person p1(1); person p2(1); cout << "p1 == p2 ? " << (p1 == p2) << endl; cin.get(); return 0; }
标签:space 简单的 person cout 判断 tor end pre false
原文地址:https://www.cnblogs.com/heben/p/9311589.html