This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Static const int as array bound inside class


Hello, it appears that g++-4.1 (or g++-4.2, Debian vers. 4.2-20070609-1) does 
not support using a static const int as an array bound inside a class. I 
wrote som example code below. This type of code is described in the 
section "Compile-time constants inside classes" on page 295 in the 
book "Thinking in C++" by Bruce Eckel from 1999. He warns that not all 
compilers have implemented this feature. Is it planned for a later version of 
g++?

Best regards,
Torquil Sørensen

/////////
Example code (from the book):

class X {
	static const int size;
	int array[size];
};

const int X::size = 100;

It gives the error message "array bound is not an integer constant"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]