I am trying to initialize an array in one of my header files from an external constant number, but I get the error: size of member 'arraysize' is not constant. Am I going about this wrong, or is there a way to do what I'm trying to do? I want to be able to control all array sizes with constants in the main module. The following below is the sample code.
/* main module*/
#include <iostream>
#include <stdlib.h>
#include "cat.h"
typedef unsigned short int ushort;
const ushort arraysize = 32;
int main()
{
cat boots;
strcpy(boots.name, "Boots");
cout >> boots.name;
return 0;
}
/* End of Main Module */
/* cat.h */
typedef unsigned short int ushort;
const extern ushort arraysize;
//extern const ushort arraysize; //Tried this both ways
class cat
{
ushort age;
char name[arraysize];
};
/* End of cat.h */