only static const integral data members can be initialize

我在类的声明里添加了 :

    //定义校屏键值
    LPCTSTR keyName = L"PERSEE//Debug";
    LPCTSTR lpCalibrationstr= L"TouchScreenCalibration ";

报错:

错误    1    error C2864: 'CAnTouchDlg::keyName' : only static const integral data members can be initialized within a class  

错误    2    error C2864: 'CAnTouchDlg::lpCalibrationstr' : only static const integral data members can be initialized within a class    f:/xiao/antouch0.0/antouch/antouch/AnTouchDlg.h    25   
错误    5    error C2864: 'CAnTouchDlg::keyName' : only static const integral data members can be initialized within a class    f:/xiao/antouch0.0/antouch/antouch/AnTouchDlg.h    24   
错误    6    error C2864: 'CAnTouchDlg::lpCalibrationstr' : only static const integral data members can be initialized within a class    f:/xiao/antouch0.0/antouch/antouch/AnTouchDlg.h    25   
看到错误5和6就明白了,其它就不用多讲了,我犯了一个很低级的错误:

类的静态数据成员不能在类的声明中初始化

只有静态的,整数常量才可以在类定义中初始化,

一般做法是不在类的声明中里面初始化静态数据结构。

 

class CAnTouchDlg : public CDialog
{
private:

    int m_Left,m_Top,m_Width,m_Height;

    CBitmap m_BackScreenBitmap;

    void ShowBattery(char num);
// 构造
public:
    CAnTouchDlg(CWnd* pParent = NULL);    // 标准构造函数

// 对话框数据
    enum { IDD = IDD_ANTOUCH_DIALOG };

    //定义校屏键值
    LPCTSTR keyName = L"PERSEE//Debug";
    LPCTSTR lpCalibrationstr= L"TouchScreenCalibration ";



protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值