下面的这个例子,我是按教程做的,可是编译不过,帮忙看一下,谢谢:)
#include<iostream>
class Rectangle
{
private:int itsTop;
int itsLeft;
int itsBotton;
int itsRight;
public:
Rectangle(int top,int left,int botton,int right);
~Rectangle(){};
int GetTop(){return itsTop};
int GetLeft(){return itsLeft};
int GetBotton(){return itsBotton};
int GetRight(){return itsRight};
void SetTop(int top){itsTop=top;};
void SetLeft(int left){itsLeft=left;};
void SetBotton(int botton){itsBotton=botton;};
void SetRight(int right){itsRight=right;};
int GetArea();
}
Rectangle::Rectangle(int top,int left,int botton,int right)
{ //编译停留在这里,提示的英文好象是构造器不能满足返回的类型(问的别人,我英语0级)
int itsTop=top;
int itsLeft=left;
int itsBotton=botton;
int itsRight=right;
}
int Rectangle::GetArea()
{
int Width=itsRight=itsLeft;
int Height=itsTop-itsBotton;
return Width*Height;
}
void main()
{
Rectangle MyRectangle(100,20,50,80);
int Area=MyRectangle.GetArea();
cout<<"Top:"<<MyRectangle.GetTop()<<endl;
cout<<"Left:"<<MyRectangle.GetLeft()<<endl;
cout<<"Botton:"<<MyRectangle.GetBotton()<<endl;
cout<<"Right:"<<MyRectangle.GetRight()<<endl;
cout<<"Area:"<<Area<<endl;
}
大侠帮忙,我请你喝酒