⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 l10_6.cpp

📁 《C++程序设计教程》电子教案及例题源码
💻 CPP
字号:
#include<iostream.h>
# include <fstream.h>
#include<string.h>
class CRect
{
private:
	char color[10];
	int left;
	int top;
	int length;
	int width;
public:
	void SetColor(char *c);
	void SetSize(int l, int w);
	void Move(int t,int l);
	void Draw();
};
void CRect::SetColor(char *c)
{
	strcpy(color, c);
}
void CRect::SetSize(int l, int w)
{
	length=l;
	width = w;
}
void CRect::Move(int t,int l)
{
	top = t;
	left = l;
}
void CRect::Draw()
{
	cout << "矩形左上角坐标为(" << left << "," << top << ")" << endl;
	cout << "矩形长和宽分别为" << length << "," << width << endl;
	cout << "矩形的颜色是" << color << endl;
}


void main()
{
	CRect r;                      
	r.SetColor("Red");
	r.Move(10,20);
	r.SetSize(100,200);
	ofstream  outfile("D:\\a.txt" , ios::out);
	outfile.write( (char *) &r , sizeof(r) );
	outfile.close();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -