Chinaunix首页 | 论坛 | 博客
  • 博客访问: 301552
  • 博文数量: 63
  • 博客积分: 1482
  • 博客等级: 上尉
  • 技术积分: 1185
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-12 19:06
个人简介

hello world!

文章分类

全部博文(63)

分类: C/C++

2011-08-17 16:21:04

一维数组长度定义

       常量表达式中可以包括常量、常变量和符号常量,但不能包含变量。也就是说,C++不允许对数组的大小作动态定义,即数组的大小不依赖于程序运行过程中变量的值。例如,下面这样定义数组是不行的:

       int n;

       cin>>n;                    //输入a数组的长度

       int an;                //企图根据n的值决定数组的长度

如果把第12行改为下面一行就合法了:

       const int n=5;            //不加const也是不会成功的

 

  1. #ifndef _SplayLabelForm_
  2. #define _SplayLabelForm_

  3. #include <QtGui>
  4. #include <QtSql>
  5. #include "databaseview.h"

  6. const int NPage=15; //最大生成的动态页

  7. class SplayLabelForm:public QDialog
  8. {
  9.     Q_OBJECT
  10. public:
  11.         SplayLabelForm(QWidget *parent=0);
  12. private:
  13.         void createMainwindow();
  14.                     。。。。
  15.          QTableView *allTableView[NPage];        //问题产生处
  16.                    。。。。。。
  17. signals:
  18.          void deleteSignal();
  19.          void refreshTableSignal(QTableView *curView); //更新表格显示

  20. private slots:
  21.         void refreshTableAll(); //更新表格显示
  22.                 。。。。。
  23. };
  24. #endif // _SplayLabelForm_
阅读(3763) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~