我用MFC框架做好程序后,根据需要,又新建文件准备建立新类,但是头文件和执行文件写好后,却不能运行,总是出现
fatal error C1010: unexpected end of file while looking for precompiled header directive的错误,请问这是怎么回事,我得类声明和函数都很简单,写法绝对正确,如果在普通的main函数下一定能运行,但是在这里就不行,是不是还应该再声明一些东西,请指教,还请问一些声明类的方法,我不希望自己写的类在MFC框架中的文件里,我想单独创建,我是新手,不要笑话我

解决方案 »

  1.   

    in your cpp file,
    #include "stdafx.h"
      

  2.   

    在你的cpp文件的最开始处添加#include "stdafx.h"
      

  3.   

    #include "xxxx.h"
    可能少了!查一下看!
      

  4.   

    还是不行,又有新的错误,说我建的新类is not a class or namespace name
      

  5.   

    //头文件
    class CLine:public CObject
    {
    protected:
    CPoint m_pStart;
    CPoint m_pEnd;

    public:
    CLine(CPoint pStart,CPoint pEnd);
    void Drawing(CDC *pDC);

    };
    //执行文件
    #include "line.h"
    #include "stdafx.h"
    #inlcude "
    CLine::CLine(CPoint pStart,CPoint pEnd)
    {
    m_pStart=pStart;
    m_pEnd=pEnd;
    }void CLine::Drawing(CDC *pDC)
    {
    pDC->MoveTo(m_pStart);
    pDC->LineTo(m_pEnd);
    }
      

  6.   

    #include "line.h"
    #include "stdafx.h"
    #inlcude "                ------------------------------------
    ------------------------------------what is here ?????
    CLine::CLine(CPoint pStart,CPoint pEnd)
    {
    m_pStart=pStart;
    m_pEnd=pEnd;
    }void CLine::Drawing(CDC *pDC)
    {
    pDC->MoveTo(m_pStart);
    pDC->LineTo(m_pEnd);
    }
      

  7.   

    #include "line.h"
    #include "stdafx.h"换成
    #include "stdafx.h"
    #include "line.h"#include "stdafx.h"一定要放在文件的第一行
    不然上面的语句不会被编译
      

  8.   

    .cpp文件
    #include "stdafx.h"
    #include "line.h".h文件,为了防止重复引用
    #if _MSC_VER > 1000
    #pragma once
    #endif
      

  9.   

    少了#include "stdafx.h"
    要放在第一行