我是个新手
void CMainFrame::OnStudentInfo() 
{
// TODO: Add your command handler code here
m_pStudentInfo = new CChildFrame();
CCreateContext Context;
Context.m_pNewViewClass = RUNTIME_CLASS(CStudentInfo);
if(!m_pStudentInfo->LoadFrame(IDR_MAINFRAME,WS_OVERLAPPEDWINDOW | FWS_PREFIXTITLE,this,&Context))
return;
m_pStudentInfo->InitialUpdateFrame(NULL,TRUE);
//禁止再次开打此窗口
m_bItemStudentInfo = FALSE;
}
上面的菜单响应函数
其中 类CStudentInfo 的定义如下 继承了CObject类
class CStudentInfo : public CObject  
{
public:
CStudentInfo();
virtual ~CStudentInfo();};
编译时错误如下:
E:\VC6.0\高校教务管理系统学生端\MainFrm.cpp(278) : error C2039: 'classCStudentInfo' : is not a member of 'CStudentInfo'
        e:\vc6.0\高校教务管理系统学生端\studentinfo.h(12) : see declaration of 'CStudentInfo'
E:\VC6.0\高校教务管理系统学生端\MainFrm.cpp(278) : error C2065: 'classCStudentInfo' : undeclared identifier
Error executing cl.exe.

解决方案 »

  1.   

    MainFrm.cpp中,你头文件studentinfo.h加在哪儿?
      

  2.   

    #include "StudentInfo.h"
    这个头文件已经加了哈
      

  3.   

    classCStudentInfo这个是不是没有声明? 和你声明的字符大小写没对上?
      

  4.   

    我在MainFram.cpp中根本就没有classCStudentInfo这个对象啊
    就在OnStudentInfo() 这个成员方法中
      

  5.   

    #include "StudentInfo.h" 是不是放在最顶上了?楼主多贴点!要看看你具体放倒什么位置!
      

  6.   

    // MainFrm.cpp : implementation of the CMainFrame class
    //#include "stdafx.h"
    #include "高校教务管理系统学生端.h"
    #include "LoginDlg.h"
    #include "MainFrm.h"
    #include "StudentInfo.h"// #include "ChoiceCourse.h"
    // #include "DelCourse.h"
    // #include "CourseList.h"
    // #include "CourseScore.h"
    // #include "CmpLevScore.h"
    // #include "CETScore.h"
    // #include "UserChange.h"
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif/////////////////////////////////////////////////////////////////////////////
    // CMainFrameIMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
    //{{AFX_MSG_MAP(CMainFrame)
    ON_WM_CREATE()
    ON_UPDATE_COMMAND_UI(ID_SYSTEM_CONNECT, OnUpdateSystemConnect)
    ON_UPDATE_COMMAND_UI(ID_SYSTEM_DISCONNECT, OnUpdateSystemDisconnect)
    ON_UPDATE_COMMAND_UI(ID_STUDENT_INFO, OnUpdateStudentInfo)
    ON_UPDATE_COMMAND_UI(ID_USER_CHANGE, OnUpdateUserChange)
    ON_UPDATE_COMMAND_UI(ID_CHOICE_COURSE, OnUpdateChoiceCourse)
    ON_UPDATE_COMMAND_UI(ID_DEL_COURSE, OnUpdateDelCourse)
    ON_UPDATE_COMMAND_UI(ID_COURSE_LIST, OnUpdateCourseList)
    ON_UPDATE_COMMAND_UI(ID_COURSE_SCORE, OnUpdateCourseScore)
    ON_UPDATE_COMMAND_UI(ID_CET_SCORE, OnUpdateCetScore)
    ON_UPDATE_COMMAND_UI(ID_COMPUTER_LEVEL_SCORE, OnUpdateComputerLevelScore)
    ON_COMMAND(ID_SYSTEM_CONNECT, OnSystemConnect)
    ON_COMMAND(ID_SYSTEM_DISCONNECT, OnSystemDisconnect)
    ON_COMMAND(ID_STUDENT_INFO, OnStudentInfo)
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()static UINT indicators[] =
    {
    ID_SEPARATOR,           // status line indicator
    ID_INDICATOR_CAPS,
    ID_INDICATOR_NUM,
    ID_INDICATOR_SCRL,
    };/////////////////////////////////////////////////////////////////////////////
    // CMainFrame construction/destructionCMainFrame::CMainFrame()
    {
    // TODO: add member initialization code here
    m_pUserChange=NULL;
    m_pStudentInfo=NULL;
    m_pChoiceCourse=NULL;
    m_pCouseList=NULL;
    m_pCouseScore=NULL;
    m_pCETScore=NULL;
    m_pCmpLevScore=NULL;
    m_pDelCouser=NULL;

    m_bLogin= FALSE;
    m_bItemUserChange= FALSE;
    m_bItemStudentInfo= FALSE;
    m_bItemChoiceCouse=FALSE;
    m_bItemCourseList= FALSE;
    m_bItemDelCourse= FALSE;
    m_bItemCourseScore=FALSE;
    m_bItemCETScore=FALSE;
    m_bItemCmpLevScore= FALSE;


    }CMainFrame::~CMainFrame()
    {
    }int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
    if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
    return -1;

    if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
    | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
    !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
    {
    TRACE0("Failed to create toolbar\n");
    return -1;      // fail to create
    }

    if (!m_wndStatusBar.Create(this) ||
    !m_wndStatusBar.SetIndicators(indicators,
    sizeof(indicators)/sizeof(UINT)))
    {
    TRACE0("Failed to create status bar\n");
    return -1;      // fail to create
    }

    // TODO: Delete these three lines if you don't want the toolbar to
    //  be dockable
    m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
    EnableDocking(CBRS_ALIGN_ANY);
    DockControlBar(&m_wndToolBar);
    ShowWindow(SW_SHOWMAXIMIZED);
    return 0;
    }BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
    {
    if( !CMDIFrameWnd::PreCreateWindow(cs) )
    return FALSE;
    // TODO: Modify the Window class or styles here by modifying
    //  the CREATESTRUCT cs

    return TRUE;
    }/////////////////////////////////////////////////////////////////////////////
    // CMainFrame diagnostics#ifdef _DEBUG
    void CMainFrame::AssertValid() const
    {
    CMDIFrameWnd::AssertValid();
    }void CMainFrame::Dump(CDumpContext& dc) const
    {
    CMDIFrameWnd::Dump(dc);
    }#endif //_DEBUG
    void CMainFrame::OnUpdateSystemConnect(CCmdUI* pCmdUI) 
    {
    // TODO: Add your command update UI handler code here
    pCmdUI->Enable(!m_bLogin);
    }void CMainFrame::OnUpdateSystemDisconnect(CCmdUI* pCmdUI) 
    {
    // TODO: Add your command update UI handler code here
    pCmdUI->Enable(m_bLogin);
    }void CMainFrame::OnUpdateStudentInfo(CCmdUI* pCmdUI) 
    {
    // TODO: Add your command update UI handler code here
    pCmdUI->Enable(m_bItemStudentInfo);
    }void CMainFrame::OnUpdateUserChange(CCmdUI* pCmdUI) 
    {
    // TODO: Add your command update UI handler code here
    pCmdUI->Enable(m_bItemUserChange);
    }void CMainFrame::OnUpdateChoiceCourse(CCmdUI* pCmdUI) 
    {
    // TODO: Add your command update UI handler code here
    pCmdUI->Enable(m_bItemChoiceCouse);
    }void CMainFrame::OnUpdateDelCourse(CCmdUI* pCmdUI) 
    {
    // TODO: Add your command update UI handler code here
    pCmdUI->Enable(m_bItemDelCourse);
    }void CMainFrame::OnUpdateCourseList(CCmdUI* pCmdUI) 
    {
    // TODO: Add your command update UI handler code here
    pCmdUI->Enable(m_bItemCourseList);
    }void CMainFrame::OnUpdateCourseScore(CCmdUI* pCmdUI) 
    {
    // TODO: Add your command update UI handler code here
    pCmdUI->Enable(m_bItemCourseScore);
    }void CMainFrame::OnUpdateCetScore(CCmdUI* pCmdUI) 
    {
    // TODO: Add your command update UI handler code here
    pCmdUI->Enable(m_bItemCETScore);
    }void CMainFrame::OnUpdateComputerLevelScore(CCmdUI* pCmdUI) 
    {
    // TODO: Add your command update UI handler code here
    pCmdUI->Enable(m_bItemCmpLevScore);
    }void CMainFrame::OnSystemConnect() 
    {
    // TODO: Add your command handler code here
    CLoginDlg dlg;
    if(dlg.DoModal()==IDOK)
    {
    m_bLogin = TRUE;
    m_bItemUserChange=TRUE;
    m_bItemStudentInfo=TRUE;
    m_bItemDelCourse=TRUE;
    m_bItemCourseScore=TRUE;
    m_bItemCourseList=TRUE;
    m_bItemCmpLevScore=TRUE;
    m_bItemChoiceCouse=TRUE;
    m_bItemCETScore=TRUE;
    }
    }void CMainFrame::OnSystemDisconnect() 
    {
    // TODO: Add your command handler code here
    if (m_pStudentInfo)
    {
    m_pStudentInfo->DestroyWindow();
    }
    if (m_pUserChange)
    {
    m_pUserChange->DestroyWindow();
    }
    if (m_pDelCouser)
    {
    m_pDelCouser->DestroyWindow();
    }
    if (m_pCouseScore)
    {
    m_pCouseScore->DestroyWindow();
    }
    if (m_pCouseList)
    {
    m_pCouseList->DestroyWindow();
    }
    if (m_pCmpLevScore)
    {
    m_pCmpLevScore->DestroyWindow();
    }
    if (m_pChoiceCourse)
    {
    m_pChoiceCourse->DestroyWindow();
    }
    if (m_pCETScore)
    {
    m_pCETScore->DestroyWindow();
    }

    m_bLogin=FALSE; m_bItemCETScore=FALSE;
    m_bItemChoiceCouse=FALSE;
    m_bItemCmpLevScore=FALSE;
    m_bItemCourseList=FALSE;
    m_bItemCourseScore=FALSE;
    m_bItemDelCourse=FALSE;
    m_bItemStudentInfo =FALSE;
    m_bItemUserChange =FALSE;

    }void CMainFrame::OnStudentInfo() 
    {
    // TODO: Add your command handler code here
    m_pStudentInfo = new CChildFrame();
    CCreateContext Context;
    Context.m_pNewViewClass = RUNTIME_CLASS(CStudentInfo);
    if(!m_pStudentInfo->LoadFrame(IDR_MAINFRAME,WS_OVERLAPPEDWINDOW | FWS_PREFIXTITLE,this,&Context))
    return;
    m_pStudentInfo->InitialUpdateFrame(NULL,TRUE);
    //禁止再次开打此窗口
    m_bItemStudentInfo = FALSE;
    }
      

  7.   

    装上VS2008转换,成功,没有出现错误,在VC6中也不出现错误,怪事