定义一个长方形(Rectangle)类,包括长度(lenth)和宽度(width)数据成员定义一个长方形(Rectangle)类,包括长度(lenth)和宽度(width)数据成员,重载“”运算符,用来实现两个长方形比较面积,例如两
<p>问题:定义一个长方形(Rectangle)类,包括长度(lenth)和宽度(width)数据成员定义一个长方形(Rectangle)类,包括长度(lenth)和宽度(width)数据成员,重载“”运算符,用来实现两个长方形比较面积,例如两<p>答案:↓↓↓<p class="nav-title mt10" style="border-top:1px solid #ccc;padding-top: 10px;">李钟华的回答:<div class="content-b">网友采纳 //ConsoleApplication4.cpp:定义控制台应用程序的入口点. // #include"stdafx.h" #include usingnamespacestd; classcMyRect { public: intm_Length;//长囧 intm_Width;//宽 booloperator(cMyRectmyRect){returnm_Length*m_Width>myRect.m_Length*myRect.m_Width;} }; int_tmain(intargc,_TCHAR*argv[]) { cMyRectrect1,rect2; coutrect2) cout
页:
[1]