student.h

来自「vc++技术内幕第四版(清华版)源码。vc++技术内幕书是vc++的权威书籍」· C头文件 代码 · 共 60 行

H
60
字号
// student.h

#ifndef _INSIDE_VISUAL_CPP_STUDENT
#define _INSIDE_VISUAL_CPP_STUDENT

class CStudent : public CObject
{
	DECLARE_DYNAMIC(CStudent)
public:
	CString m_strName;
	int m_nGrade;

	CStudent()
	{
		m_nGrade = 0;
	}

	CStudent(const char* szName, int nGrade) : m_strName(szName)
	{
		m_nGrade = nGrade;
	}

	CStudent(const CStudent& s) : m_strName(s.m_strName)
	{
		// copy constructor
		m_nGrade = s.m_nGrade;
	}

	const CStudent& operator =(const CStudent& s)
	{
		m_strName = s.m_strName;
		m_nGrade = s.m_nGrade;
		return *this;
	}

	BOOL operator ==(const CStudent& s) const
	{
		if ((m_strName == s.m_strName) && (m_nGrade == s.m_nGrade)) {
			return TRUE;
		}
		else {
			return FALSE;
		}
	}

	BOOL operator !=(const CStudent& s) const
	{
		// Let抯 make use of the operator we just defined!
		return !(*this == s);
	}

#ifdef _DEBUG
	void Dump(CDumpContext& dc) const;
#endif // _DEBUG
};

typedef CTypedPtrList<CObList, CStudent*> CStudentList;

#endif // _INSIDE_VISUAL_CPP_STUDENT

⌨️ 快捷键说明

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