c++问题!!!!!!!

来源:百度知道 编辑:UC知道 时间:2024/06/08 15:39:43
// proj3.cpp
#include<iostream>
using namespace std;
class MyPoint{ //表示平面坐标系中的点的类
double x;
double y;
public:
MyPoint (double x,double y){this->x=x;this->y=y;}
double getX()const{ return x;}
double getY()const{ return y;}
void show()const{ cout<<'('<<x<<','<<y<<')';}
};
class MyRectangle{ //表示矩形的类
MyPoint up_left; //矩形的左上角顶点
MyPoint down_right; //矩形的右下角顶点
public:
MyRectangle(MyPoint upleft,MyPoint downright);
MyPoint getUpLeft()const{ return up_left;} //返回左上角坐标
MyPoint getDownRight()const{ return down_right;} //返回右下角坐标
MyPoint getUpRight()const; //返回右上角坐标
MyPoint getDownLeft()const; //返回左下角坐标
double area()const; //返回矩形的面积
};
//**1** **********found**********
MyRecta

(1) MyPoint p1, MyPoint p2
变量初始化,规定的格式就是这样,没有为什么

(2) down_right.getY(),up_left.getX()
返回左下角坐标,即右下角的y和左上角的x

(3) double MyRectangle::
函数返回值类型,别忘了写类名和域操作符