C++ B树类实现:表达式必须具有常量值?
假设我们有一个“itemtype.h”头文件,我在其中声明以下项:C++ B树类实现:表达式必须具有常量值?,c++,b-tree,constant-expression,C++,B Tree,Constant Expression,假设我们有一个“itemtype.h”头文件,我在其中声明以下项: #include<iostream> #include<fstream> using namespace std; const int keyfieldmax=12; const int kfmaxplus=keyfieldmax+1; const int datafieldmax=36; const int dfmaxplus=datafieldmax+1; const int NULLCHAR=
#include<iostream>
#include<fstream>
using namespace std;
const int keyfieldmax=12;
const int kfmaxplus=keyfieldmax+1;
const int datafieldmax=36;
const int dfmaxplus=datafieldmax+1;
const int NULLCHAR='\0';
typedef char keyfieldtype[kfmaxplus];
typedef char datafieldtype[dfmaxplus];
typedef struct
{
keyfieldtype keyfield;
datafieldtype datafield;
}itemType;
但有以下两行
itemType Key[maxkeys];
long branch[maxkeysplus];
它说表达式必须有常量值。那么我应该如何修复它呢?将maxkeys和maxkeysplus设为常量int
const int maxkeys = 11;
const int maxkeysplus = maxkeys + 1;
将maxkeys和maxkeysplus设为常量int
const int maxkeys = 11;
const int maxkeysplus = maxkeys + 1;
@dato再次检查。您可能错过了一个
常量
@dato:请执行完整重建以确保。如果让这些行const
@dat再次检查,则不应出现完全相同的错误。您可能错过了一个常量
@dato:请执行完整重建以确保。如果您将这些行设置为const
,则不应出现完全相同的错误。