Lsimos😈
牛奶lmy
关注数: 10
粉丝数: 112
发帖数: 1,109
关注贴吧数: 20
求问青岛到启东汽车据说在潜艇学院上车的,几点钟啊,急用 如题!!
中卫搭配求评价 博阿滕+胡梅尔斯怎么样?
普卡第一闪47j才来 西甲包2个开出来的,话不多说,上图
有人要吗? 贝拉尔迪银卡,w皮尔洛
据说今年的学弟学妹考得很不错呢,学长欣慰啊。 欢迎大家报考东大哦!!!!
TX搞什么啊 抽个卡算是1000无语
前锋屌丝专用推荐几个,谢谢 如题
克罗斯好用嘛? 打CAM?
求推荐个前腰吧,屌丝用的, 如题
前腰问题 刚抽到梅西他娘,前腰用哪个?还有个詹姆斯罗德里格斯
有没有推荐屌丝用的RB?? 如题
RB选哪个好 现在用萨巴莱塔,抽到个麦孔怎么样
贝拉儿迪好用不,感觉o贝尔不怎么好用啊 如题
求大神解答 #include<iostream> using namespace std; class Rectangle { int left,top; int right,bottom; private: static int counter; //注意私有性 public: Rectangle() { ++counter;cout<<"对象数量="<<counter<<'\n'; } ~Rectangle() { --counter;cout<<"对象数量="<<counter<<'\n'; } Rectangle(int l=0,int t=0,int r=0,int b=0); //构造函数,带默认参数,默认值全0 void Assign(int l,int t,int r,int b); void SetLeft(int u) {left=u;} //以下4个函数均为内联成员函数 void SetRight(int u) {right=u;} void SetTop(int u) {top=u;} void SetBottom(int u) {bottom=u;} //注意分号在花括号里面 void Show(); Rectangle operator+=(Rectangle &); Rectangle operator-=(Rectangle &); Rectangle operator+(Rectangle &); Rectangle operator-(Rectangle &); }; int Rectangle::counter=0; //对静态数据成员的定义性说明 Rectangle::Rectangle(int l,int t,int r,int b) /*带默认参数的构造函数,声明中 已经指定默认值为0*/ { left=l;top=t; right=r;bottom=b; } void Rectangle::Assign(int l,int t,int r,int b) { left=l;top=t; right=r;bottom=b; } void Rectangle::Show() { cout<<"left-top point is ("<<left<<","<<top<<")"<<'\n'; cout<<"right-bottom point is ("<<right<<","<<bottom<<")"<<endl; } Rectangle Rectangle::operator+=(Rectangle & rect) { int x=rect.right-rect.left; int y=rect.bottom-rect.top; right+=x; bottom+=y; return Rectangle(left,right,top,bottom); } Rectangle Rectangle::operator-=(Rectangle & rect) { int x=rect.right-rect.left; int y=rect.bottom-rect.top; right-=x; bottom-=y; return Rectangle(left,right,top,bottom); } Rectangle Rectangle::operator+(Rectangle & rect) { return Rectangle(left+rect.left,right+rect.right,top+rect.top,bottom+rect.bottom); } Rectangle Rectangle::operator-(Rectangle & rect) { return Rectangle(left-rect.left,right-rect.right,top-rect.top,bottom-rect.bottom); } int main() { Rectangle rect(0,0,0,0); //默认值全0 cout<<"初始的rect:"<<endl; rect.Show(); rect.Assign(100,200,300,400); cout<<"赋值后的rect:"<<endl; rect.Show(); Rectangle rect1(0,0,200,200); cout<<"初始的rect1:"<<endl; rect1.Show(); rect+=rect1; cout<<"与rect1相加后的rect:"<<endl; rect.Show(); rect-=rect1; cout<<"减去rect1后的rect:"<<endl; rect.Show(); Rectangle rect2(200,100,200,100); rect2=rect+rect1; cout<<"rect与rect1相加所得的rect2:"<<endl; rect2.Show(); rect2=rect-rect1; cout<<"rect减去rect1所得的rect2:"<<endl; rect2.Show(); Rectangle count[4]; return 0; } 为什么运行之后对象数量为负数
1
下一页