error C2146: syntax error : missing ';' before identifier 'm_cControlPos'
error C2501: 'CControlPos' : missing storage-class or type specifiers
error C2501: 'm_cControlPos' : missing storage-class or type specifiers加入一个头文件 #include "ControlPos.h"
在自己的类下加入:CControlPos m_cControlPos;后出现上面三处错误,
本人新手,不知如何解决,请高手帮忙

解决方案 »

  1.   

    ControlPos.cpp也要添加到工程里的
      

  2.   

    1、重新编译一次(指的是清空后再重头编译)。2、上面那步不行的话,看看这个头文件是否要与哪个库(.lib)文件合起来使用,所以将该库文件引入工程中。3、检查头文件加入的位置是否正确,先把头文件直接放在需要使用的cpp文件头部。
      

  3.   

    ControlPos.cpp 我已添加到工程里了,难道我放的位置不对?我放在这个工程的文件夹下
      

  4.   

    missing ';' before identifier 'm_cControlPos' 
      

  5.   

    将.h文件对应的Cpp文件加入工程。
    如果是一个Dll的话 要将.h对应的.lib文件加入工程
      

  6.   

    ControlPos.cpp这个文件我已经放在工程文件夹下了,还需要设置什么吗?
      

  7.   

    把你的ControlPos.h贴上来看看
    这个错误不是找不到cpp的问题,是找不到这个类定义的问题,所以看看你的ControlPos.h里面是怎么定义的
      

  8.   

    //------------------------------------------------------------------------------
    // ControlPos.h
    // 
    // CControlPos 
    // Position controls on a form's resize 
    // 
    // Copyright (c) 2000 Paul Wendt
    // 
    // VERSION# DATE NAME DESCRIPTION OF CHANGE
    // -------- ---------- ---- ---------------------
    // 1.01   07/11/2000 PRW Original creation.
    // 
    #ifndef CONTROLPOS_H_
    #define CONTROLPOS_H_//----------------------------------------------
    // these #define's specify HOW the control
    // will move. they can be combined with the
    // bitwise or operator
    //
    #define CP_MOVE_HORIZONTAL 1
    #define CP_MOVE_VERTICAL 2
    #define CP_RESIZE_HORIZONTAL 4
    #define CP_RESIZE_VERTICAL 8class CControlPos
    {
    public:
    CControlPos(CWnd* pParent = NULL);
    virtual ~CControlPos();public:
    void SetParent(CWnd* pParent); BOOL AddControl(CWnd* pControl, const DWORD& dwStyle = CP_MOVE_HORIZONTAL);
    BOOL AddControl(const UINT& unId, const DWORD& dwStyle = CP_MOVE_HORIZONTAL);
    BOOL RemoveControl(CWnd* pControl);
    BOOL RemoveControl(const UINT& unId);
    void ResetControls(void);
    virtual void MoveControls(void); //---------------------------------------------------
    // most of the time, you don't want to move controls
    // if the user reduces window size [controls can
    // overlap and cause "issues"]
    // negative moves won't move controls when the parent
    // window is getting smaller than its original size
    //
    void SetNegativeMoves(const BOOL& fNegativeMoves = TRUE);
    BOOL GetNegativeMoves(void) const;protected:
    virtual void UpdateParentSize(void);private:
    CWnd*  m_pParent;
    int    m_nOldParentWidth;
    int    m_nOldParentHeight;
    int    m_nOriginalParentWidth;
    int    m_nOriginalParentHeight;
    BOOL   m_fNegativeMoves; CObArray m_awndControls;
    };//----------------------------------------------------
    // internal structure used to hold all information
    // about a CWnd* control
    //
    typedef struct tagCONTROLDATA
    {
    HWND  hControl; // HWND's never change; some MFC functions return temporary CWnd *'s
    DWORD dwStyle; // check the #define's above
    } CONTROLDATA, *LPCONTROLDATA;#endif
      

  9.   

    貌似木有问题哦
    唯一能想到的可能了:搜索一下你整个工程中的文件,看是否有其他的文件里面也有如下这行:
    #define CONTROLPOS_H_ 如果在其他头文件里面也有这个定义,那么在你的类所在头文件里面,可能无法引入这个class
      

  10.   

    出错这一行就是 CControlPos m_cControlPos;
      

  11.   

    你的这个类CControlPos,还是没有给识别出来.你include了头文件了吗?,
    注意大小写,等等
      

  12.   

    你CPP只放到了目录下,有没有在工程里加入呢?
    Add -> Existing Item -> 那个什么CPP文件。
    一个小建议。 不一定对。 呵呵
      

  13.   

    CControlPos m_cControlPos;后出现上面三处错误, 这行语句的前后是什么
      

  14.   

    你是不是只在文件中用#include包含了那个头文件,而没有把那个头添加到工程中啊?
      

  15.   

    ControlPos.h 和 ControPos.cpp全放在工程下了
      

  16.   

    也有可能是头文件包含顺序问题,确认你在声明CControlPos m_cControlPos;之前已经
    #include "ControlPos.h"
    最简单的是在你的类的头文件中类声明之前包含。
    如还有问题,将代码打包发给我看看(打包前清理、删除DEBUG、Release目录)
      

  17.   

    你是在哪里实例化CControlPos m_cControlPos这个对象的?
    不会是在CControlPos 类中吧?
    如果是的话,类本身没有定义完,怎么实例化对象呢?
    要在其他文件中实例化
    不知道对你有没有帮助
      

  18.   

    我是在自己的类下声明的CControlPos m_cControlPos;请25楼 Mackz前辈留下邮件,我会把程序发给你,请你帮我看看,不盛感激