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

📄 第六章3.txt

📁 本书在复习C++基础知识后
💻 TXT
字号:
// 在Ex_StudentDoc.h文件中的class CEx_StudentDoc前添加的
class CStudent : public CObject
{
	CString strName;				// 姓名
	CString strID;				// 学号
	float fScore1, fScore2, fScore3;	// 三门成绩
	float fAverage;				// 平均成绩
	DECLARE_SERIAL(CStudent)
public:
	CStudent() {};
	CStudent(CString name, CString id, float f1, float f2, float f3);
	void Serialize(CArchive &ar);
	void Display(int y, CDC *pDC);	// 在坐标为(0,y)处显示数据
};
// 在Ex_StudentDoc.cpp文件中添加的CStudent实现代码
CStudent::CStudent(CString name, CString id, float f1, float f2, float f3)
{
	strName = name;
	strID = id;
	fScore1 = f1;
	fScore2 = f2;
	fScore3 = f3;
	fAverage = (float)((f1 + f2 + f3)/3.0);
}
void CStudent::Display(int y, CDC *pDC)
{
	CString str;
	str.Format("%s  %s  %f  %f  %f  %f", strName, strID,
		fScore1, fScore2, fScore3, fAverage);
	pDC->TextOut(0, y, str);
}
IMPLEMENT_SERIAL(CStudent, CObject, 1)
void CStudent::Serialize(CArchive &ar)
{
	if (ar.IsStoring())
		ar<<strName<<strID<<fScore1<<fScore2<<fScore3<<fAverage;
	else
		ar>>strName>>strID>>fScore1>>fScore2>>fScore3>>fAverage;
}

⌨️ 快捷键说明

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