我在类的声明里添加了 :
//定义校屏键值
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 支持
}