有关类和对象问题的求助,程序是这个样子的,红字是下划线
开糖手杰克 2017-12-03 06:58:55 #include<iostream>
using namespace std;
class Rectangle
{
public :
void Coordiate(float newL=0,float newD=0,float newR=0,float newT=0);
void getArea();
private:
float left,down,right,top;
};
void Rectangle::Coordiate(float newL,float newD,float newR,float newT)
{
cin>>newL>>newD>>newR>>newT;
left=newL;
down=newD;
right=newR;
top=newT;
}
inline void getArea(){
float Long,Wide;
Long=right-left;//表达式必须是指向完整类型的指针
Wide=top-down;//这里的top和down都被说是没有定义??
float Area=Long*Wide;
cout<<Area<<endl;
}
int main(){
Rectangle myRectangle;
cout<<"依次输入左下角和右下角的坐标"<<endl:
myRectangle.Coordiate();
myRectangle.getArea();
return 0;
}