c编程题讲述
4.1测试一个名为rectangle的矩形类,其属性为矩形的左下角与右上角两个点的坐标,能计算矩形的面积。
解:
源程序:
#include iostream.h
class Rectangle
{
public:
Rectangle (int top, int left, int bottom, int right);
~Rectangle () {}
int GetTop() const { return itsTop; }
int GetLeft() const { return itsLeft; }
int GetBottom() const { return itsBottom; }
int GetRight() const { return itsRight; }
void SetTop(int top) { itsTop = top; }
void SetLeft (int left) { itsLeft = left; }
void SetBottom (int bottom) { itsBottom = bottom; }
void SetRight (int right) { itsRight = right; }
int GetArea() const;
private:
int itsTop;
int itsLeft;
int itsBot
您可能关注的文档
最近下载
- 铸牢中华民族共同体意识面临的挑战与应对.docx VIP
- 2025年北方工业大学工商管理专业《管理学》科目期末试卷及答案.docx VIP
- (二模)苏北七市2026届高三第二次调研考试语文试卷(含官方答案).docx
- 跨文化交际角度鉴赏电影《刮痧》.ppt VIP
- 高三英语课件《HOW TO MAKE AN English Poster》.pptx VIP
- 细胞与基因治疗(CGT)CDMO市场现状.docx VIP
- 汽轮机低压缸进汽道气动性能改进地研究.pdf VIP
- 加辅料炒法麸炒.ppt VIP
- GB 51142-2015 液化石油气供应工程设计规范.docx VIP
- 《社会工作实务》助理社会工作师考试综合测试题(含答案及解析).docx VIP
原创力文档

文档评论(0)