多文件及复制构造函数实例_默认复制构造函数
多文件及复制构造函数实例由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“默认复制构造函数”。
#include//保存为rect.cpp #include”rect.h”
using namespace std;
Rectangle::Rectangle(intl,intt,intr,int b){left=l;top=t;right=r;bottom=b;} Rectangle::Rectangle(Rectangle &rec){left=rec.left;top=rec.top;
right=rec.right;bottom=rec.bottom;} void Rectangle::Aign(intl,intt,intr,int b){
} left=r;top=t;right=r;bottom=b;} cout
cla Rectangle{//保存为rect.hintleft,top,right,bottom;
public:
Rectangle(int l=0,intt=0,int r=0,int b=0);Rectangle(Rectangle &rec);
};~Rectangle(){};void Aign(int ,int ,int ,int);voidSetleft(int t){left=t;} voidSetRight(int t){right=t;} voidSettop(int t){top=t;} voidSetBottom(int t){bottom=t;;} void Show();
#include“rect.cpp”
#include
using namespace std;
int main(){
Rectangle rect;
} rect.Show();rect.Aign(100,200,300,400);rect.Show();Rectangle rect1(0,0,200,200);rect1.Show();Rectangle rect2(rect1);cout