帮忙写个C++程序啊,考试需要,希望帮帮忙!!!!!!

来源:百度知道 编辑:UC知道 时间:2024/05/23 10:37:12
用C++写一个程序,定义一个矩形类rectangle,它由左上角坐标、长和宽描述。这个类得公用成员函数Is in or out 用于判断一个输入或输出坐标是否在一个矩形对象内,如果在,返回true,否则返回false

class rectangle{
public:
rectangle(int x,int y,int width,int height){
x_pos=x;
y_pos=y;
m_width=width;
m_height=height;
};
bool Isinorout(int x,int y){
if(x>x_pos&&x<x_pos+m_width&&y>y_pos&&y>y_pos+m_height)
return 1;
else
return 0;
};
private:
int m_width;
int m_height;
int x_pos;
int y_pos;
};
简单了点,但能实现功能。