1

Suppose that we have a "itemtype.h" header file, where I declare the following items:

#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;

Now, from this header I need to create "btree.h"

#include "table.h"
int maxkeys=11;
int maxkeysplus=maxkeys+1;
const int minkeys=5;
const int nilptr=-1L;
typedef struct
{
    int count;
    itemType Key[maxkeys];
    long branch[maxkeysplus];
}NodeType

but with the following two lines

itemType Key[maxkeys];
long branch[maxkeysplus];

it says that expression must have constant values. So how should I fix it?

Bart
  • 19,692
  • 7
  • 68
  • 77

1 Answers1

1

Make maxkeys and maxkeysplus a const int

const int maxkeys = 11;
const int maxkeysplus = maxkeys + 1;
Darren
  • 68,902
  • 24
  • 138
  • 144