MFC 实训中的学生类(自主添加)


// 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 XStudent   

public: 
    XStudent(); 
    XStudent(const XString &name,int num,int score); 
    void Display(CDC*,int,int); 
    virtual ~XStudent(); 
private: 
     XString name; 
     int num;
     int score ; 
 
}; 
 
#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  
//  
 
XStudent::XStudent(const CString &name,int n,int s):name(name),num(n),score(s)

     

void XStudent::Display(CDC *pDC,int x,int y) 

    CString str; 
    str.Format("姓名:%s,学号:%d,分数:%d",name,num,score); 
    pDC->TextOut(x,y,str); 

 
XStudent::~XStudent() 

 

 
 
 
 
 
#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  
 
/  
// XStudentView  
 
IMPLEMENT_DYNCREATE(XStudentView, XView) 
 
BEGIN_MESSAGE_MAP(XStudentView, XView) 
    //{{AFX_MSG_MAP(XStudentView)  
        // 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, XView::OnFilePrint) 
    ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) 
    ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) 
END_MESSAGE_MAP() 
 
/  
// XStudentView construction/destruction  
 
XStudentView::XStudentView() 

     // TODO: add construction code here  
 

 
XStudentView::~XStudentView() 


 
BOOL XStudentView::PreCreateWindow(CREATESTRUCT& cs) 

    // TODO: Modify the Window class or styles here by modifying  
    //  the CREATESTRUCT cs  
 
    return CView::PreCreateWindow(cs); 

 
/  
// XStudentView drawing  
 
void XStudentView::OnDraw(CDC* pDC) 

    XStudentDoc* pDoc = GetDocument(); 
    ASSERT_VALID(pDoc); 
    // TODO: add draw code for native data here  
    CStudent st1("李姗",201258503105,60); 
    st1.Display(pDC,20,20); 

 
/  
// XStudentView printing  
 
BOOL XStudentView::OnPreparePrinting(XPrintInfo* pInfo) 

    // default preparation  
    return DoPreparePrinting(pInfo); 

 
void XStudentView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 

    // TODO: add extra initialization before printing  

 
void XStudentView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 

    // TODO: add cleanup after printing  

 
/  
// XStudentView diagnostics  
 
#ifdef _DEBUG  
void CStudentView::AssertValid() const 

    XView::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  
 
/  
// XStudentView message handlers 
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值