定义一数组表
const int CRobotDlg::m_paDis[27]={-1,-2,-3,-4,-5,-6,-7,-8,-9,-10,-11,-12,-13,-14,13,12,11,10,9,8,7,6,5,4,3,2,1};
但是编译时出现syntax error:"{"
这是为什么?

解决方案 »

  1.   

    const 成员变量只能在构造函数初始化表里面完成初始化,不能在全局中完成初始化。
    ============================================================================
    提问题时标题要简明扼要地说明问题内容,切忌使用"急","求救"之类不能说明问题的标题
    http://www.betajin.com/alphasun/index.htm          给我发信息请附带原帖地址
    http://alphasun.18en.com/                    http://shakingtoolkit.9126.com/
    DocWizard C++程序文档自动生成工具 | Wave OpenGL | HttpProxy | AjaxParser词法分析
      

  2.   

    你可以做如下修改:
    在.h中改成如下定义:
    static const int m_paDis[27];
    在.cpp 中做如下初始化:
    const int m_paDis[27]={-1,-2,-3,-4,-5,-6,-7,-8,-9,-10,-11,-12,-13,-14,13,12,11,10,9,8,7,6,5,4,3,2,1};
    // 在#include 语句之后,construct function 之前
      

  3.   

    我使用了 databasesql(程序人生) 的方法,但是还是出错,显示
    unresolved external symbol "public:static int const * const CRobotDlg::m_paDis"
      

  4.   

    你在InitDialog() 里边初始化,看有没有问题
      

  5.   

    // CMyDialog.h
    class CMyDialog : public CDialog
    {
    // Construction
    public:
    ...................
    static const int m_paDis[27];
    ...................};
    // MyDialog.cpp : implementation file
    //#include "stdafx.h"
    #include "DlgTitle.h"
    #include "MyDialog.h"#ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif/////////////////////////////////////////////////////////////////////////////
    // CMyDialog dialog
    const int m_paDis[27]={-1,-2,-3,-4,-5,-6,-7,-8,-9,-10,-11,-12,-13,-14,13,12,11,10,9,8,7,6,5,4,3,2,1};CMyDialog::CMyDialog(CWnd* pParent /*=NULL*/)
    : CDialog(CMyDialog::IDD, pParent)
    {
    //{{AFX_DATA_INIT(CMyDialog)
    // NOTE: the ClassWizard will add member initialization here
    //}}AFX_DATA_INIT
    }
    楼主这回可明白了?
      

  6.   

    没错啊,我就是这么整的,编译没错,连结事发生错误.
    郁闷!!!!!
    unresolved external symbol "public:static int const * const CRobotDlg::m_paDis"