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

📄 l10_10.cpp

📁 《C++程序设计教程》-杨国兴-电子教案及例题 C++程序设计PPT课件 html课件 例题
💻 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  rt;
	ifstream  ifs( "data.txt" );
	ifs.seekg( 0, ios::end );
	streampos  lof = ifs.tellg();     
	ifs.seekg( -lof/10, ios::end );
	ifs.read( (char *)&rt , sizeof(CRect) );
	ifs.close();
	rt.Move(100,100);
	ofstream  ofs( "data.txt", ios::ate );   
	ofs.seekp( -lof/10, ios::end );
	ofs.write( (char *)&rt , sizeof(CRect) );
	ofs.close();


}

⌨️ 快捷键说明

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