设计一个矩形类 包括构造函数 析构函数 GET SET函数 重载运算符 + 将两个矩形相加
来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/06/05 20:06:59
设计一个矩形类 包括构造函数 析构函数 GET SET函数 重载运算符 + 将两个矩形相加
class Rectangle
{int left,top;
int right,bottom;
public:
Rectangle(int l=0,int t=0,int r=0,int b=0);
Rectangle(){};
void Assign(int l,int t,int r,int b);
void SetLeft(int t){left=t;}
void SetRight(int t){right=t;}
void SetTop(int t){top=t;}
void SetBottom(int t){bottom=t;}
void show();
void operator+=(Rectangle&);
void operator-=(Rectangle&);
/*void operator*=(Rectangle&);*/
friend Rectangle operator +(Rectangle&,Rectangle&);
friend Rectangle operator-(Rectangle&,Rectangle&);
/*friend Rectangle operator*(Rectangle&,Rectangle&);*/
};
#include
#include "rect.h"
using namespace std;
Rectangle::Rectangle(int l,int t,int r,int b){
left=l;top=t;
right=r;bottom=b;
}
void Rectangle::Assign(int l,int t,int r,int b)
{
void Rectangle::show(){
cout
{int left,top;
int right,bottom;
public:
Rectangle(int l=0,int t=0,int r=0,int b=0);
Rectangle(){};
void Assign(int l,int t,int r,int b);
void SetLeft(int t){left=t;}
void SetRight(int t){right=t;}
void SetTop(int t){top=t;}
void SetBottom(int t){bottom=t;}
void show();
void operator+=(Rectangle&);
void operator-=(Rectangle&);
/*void operator*=(Rectangle&);*/
friend Rectangle operator +(Rectangle&,Rectangle&);
friend Rectangle operator-(Rectangle&,Rectangle&);
/*friend Rectangle operator*(Rectangle&,Rectangle&);*/
};
#include
#include "rect.h"
using namespace std;
Rectangle::Rectangle(int l,int t,int r,int b){
left=l;top=t;
right=r;bottom=b;
}
void Rectangle::Assign(int l,int t,int r,int b)
{
void Rectangle::show(){
cout
设计一个矩形类 包括构造函数 析构函数 GET SET函数 重载运算符 + 将两个矩形相加
设计一个矩形类 有构造函数 析构函数 GET函数 SET函数以及下列重载的运算符 重载加法运算符+ 将两个矩形相
编一个程序,用成员函数重载运算符“+”和“-”,将两个矩阵(这两个矩阵均为2行3列)相加和相减.
为矩形类定义复制构造函数
设计出矩形类,具有长宽,构造函数,析构函数和其他成员函数,并输出当前长,宽,面积.
设计一个名为Rectangle的矩形类,其属性为矩形的左下角与右上角两个点的坐标,能计算矩形的面积.要有构造函数并实现,
如何将运算符重载函数重载成一般函数形式
编写一个三角形类,数据成员为三边长,成员函数计算周长、面积,定义两个重载的构造 c++
用C++语言 定义复数类complex,使用成员函数重载运算符+-,使用友元函数重载运算符.
设计Person和Student类,实现二者的继承关系,要求包含至少一个构造函数以及所有成员的set和Get,以及能够现
设计一个圆类(circle),数据成员包括radius(圆半径);成员函数包括:1、构造函数(要求对构造函数进行重
定义一个矩形类,成员函数用来计算长方形的周长和面积,矩形的长与宽由构造函数初始