Mail Archives: djgpp/1999/08/23/18:43:25
i used to define my constants like this, following advice by someone
who seemed to understand the ansi/iso c++ declaration:
class c{
const char cszText[] = "Text";
const int ciNumber = 5;
};
in version 2.95 of gcc this results in a compiler error. now i wonder
how am i supposed to initialize constants. i found out by trying that
the compiler accepts defining the consts values in the constructor,
like this:
c::c() : cszText("Text"), ciNumber(5) {}
but in this case i would have to initialize class member cszText with
a fixed value in the class definition and wherever i use ciNumber for
defining const values this results in another compiler error, because
the value of ciNumber is not defined in the header-file, for instance:
class c{
// same as above
char szBuffer[ciNumber];
};
does not work any more...
do i have to use #define's again like?!
or is there another way to cope with these things?
cheers
mimo
- Raw text -