'array bound is not an integer constant' when defining size of array in class, using an element of a const array
Posted
by
user574733
on Stack Overflow
See other posts from Stack Overflow
or by user574733
Published on 2011-01-13T19:14:58Z
Indexed on
2011/01/13
19:53 UTC
Read the original article
Hit count: 170
#ifndef QWERT_H
#define QWERT_H
const int x [] = {1, 2,};
const int z = 3;
#endif
#include <iostream>
#include "qwert.h"
class Class
{
int y [x[0]]; //error:array bound is not an integer constant
int g [z]; //no problem
};
int main ()
{
int y [x[0]]; //no problem
Class a_class;
}
I can't figure out why this doesn't work. Other people with this problem seem to be trying to dynamically allocate arrays. Any help is much appreciated.
© Stack Overflow or respective owner