ex010205doc.cpp

来自「深入浅出Visual C++入门进阶与应用实例 随书光盘 作者 何志丹」· C++ 代码 · 共 109 行

CPP
109
字号
// Ex010205Doc.cpp : implementation of the CEx010205Doc class
//

#include "stdafx.h"
#include "Ex010205.h"

#include "Ex010205Doc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CEx010205Doc

IMPLEMENT_DYNCREATE(CEx010205Doc, CDocument)

BEGIN_MESSAGE_MAP(CEx010205Doc, CDocument)
	//{{AFX_MSG_MAP(CEx010205Doc)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEx010205Doc construction/destruction

CEx010205Doc::CEx010205Doc()
{
	CStudent stu ;
	stu.m_iStuNo = 1000 ;
	stu.m_iScore = 99 ;
	m_arStus.Add(stu);

	stu.m_iStuNo = 1001 ;
	stu.m_iScore = 59 ;
	m_arStus.Add(stu);

	stu.m_iStuNo = 1002 ;
	stu.m_iScore = 79 ;
	m_arStus.Add(stu);

	i_CurStu = m_arStus[0] ;
}

CEx010205Doc::~CEx010205Doc()
{
}

BOOL CEx010205Doc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CEx010205Doc serialization

void CEx010205Doc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
		// TODO: add loading code here
	}
}

/////////////////////////////////////////////////////////////////////////////
// CEx010205Doc diagnostics

#ifdef _DEBUG
void CEx010205Doc::AssertValid() const
{
	CDocument::AssertValid();
}

void CEx010205Doc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CEx010205Doc commands

bool CEx010205Doc::SetCurStu(int iStuNo)
{
	for(int i = m_arStus.GetSize() - 1 ; i >= 0 ; i-- )
		if( iStuNo == m_arStus[i].m_iStuNo )
		{
			i_CurStu = m_arStus[i] ;
			break ;
		}
		
		return (i >= 0 ) ;//i >=0 表示已经找到,否则表示没有找到
}

⌨️ 快捷键说明

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