書式#include <iostreamの> //オーバーロード"演算子=="外のクラス // ==是二元操作符 ////////////////////////// //////////////////////////////// クラス長方形 { パブリック: 矩形(W INT、INT H) :幅(W) 、高さ(H) {}。 〜矩形(){}。 //ブール演算子==(長方形&REC); 公共: int型の幅; int型の高さ。 }。 ////////////////////////////////////////////////// //////// ブール演算子==(長方形&THS、長方形&REC) { リターンths.height == rec.height && ths.width == rec.width。 } ///////////////////////////////////////////////// ///////// メイン()がINT { 矩形(40、10)。 矩形B(40、10)。 矩形C(4、10)。 std :: coutの<<(== b)の<<はstd ::てendl; std :: coutの<<(== C)<<はstd ::てendl; std :: COUT <<(B == C)<<はstd :: ENDL。 0を返します。 }