// Student1.h: interface for the CStudent class.
//
//
#if !defined(AFX_STUDENT1_H__6C489F85_8EF3_473A_BD60_004F7B036622__INCLUDED_)
#define AFX_STUDENT1_H__6C489F85_8EF3_473A_BD60_004F7B036622__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CStudent
{
public:
CStudent();
CStudent(const CString &name,int english);
void Display(CDC*,int,int);
virtual ~CStudent();
private:
CString name;
int english;
};
#endif // !defined(AFX_STUDENT1_H__6C489F85_8EF3_473A_BD60_004F7B036622__INCLUDED_)
// Student1.cpp: implementation of the CStudent class.
//
//
#include "stdafx.h"
#include "student.h"
#include "Student1.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//
// Construction/Destruction
//
CStudent::CStudent(const CString &name,int english):name(name),english(english)
{
}
void CStudent::Display(CDC *pDC,int x,int y)
{
CString str;
str.Format("姓名:%s,英语成绩:%d",name,english);
pDC->TextOut(x,y,str);
}
CStudent::~CStudent()
{
}
// studentView.cpp : implementation of the CStudentView class
//
#include "stdafx.h"
#include "student.h"
#include "studentDoc.h"
#include "studentView.h"
#include "Student1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/
// CStudentView
IMPLEMENT_DYNCREATE(CStudentView, CView)
BEGIN_MESSAGE_MAP(CStudentView, CView)
//{{AFX_MSG_MAP(CStudentView)
// 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
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/
// CStudentView construction/destruction
CStudentView::CStudentView()
{
// TODO: add construction code here
}
CStudentView::~CStudentView()
{
}
BOOL CStudentView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/
// CStudentView drawing
void CStudentView::OnDraw(CDC* pDC)
{
CStudentDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CStudent st1("小丽",90);
st1.Display(pDC,20,20);
}
/
// CStudentView printing
BOOL CStudentView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CStudentView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CStudentView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/
// CStudentView diagnostics
#ifdef _DEBUG
void CStudentView::AssertValid() const
{
CView::AssertValid();
}
void CStudentView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CStudentDoc* CStudentView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CStudentDoc)));
return (CStudentDoc*)m_pDocument;
}
#endif //_DEBUG
/
// CStudentView message handlers
添加学生类
最新推荐文章于 2022-03-25 19:04:07 发布