你自己对照一下,改好了。看我改的这么辛苦,采纳我吧。。。
#include "stdafx.h"
#include
#include
using namespace std;
class rectangle
{
private:
int length,width;
public:
rectangle(){};
rectangle(int a,int b);
rectangle tlength(rectangle A,rectangle B);
void display(rectangle C);
};
rectangle::rectangle(int a,int b)
{
length=a;width=b;
}
rectangle rectangle::tlength(rectangle A,rectangle B)
{
A.length= A.length + B.length;
A.width=A.width+B.width;
return A;
}
void rectangle::display(rectangle C)
{
cout<<(C.length+C.width)*2;
}
void main()
{
rectangle A(1,2),B(3,4),C;
C=C.tlength(A,B);
C.display(C);
}