I defines FileLogConstant class as following.
class FileLogConstant
{
public:
static const INT32 REGISTER_LOGGER ;
static const INT32 REGISTER_METHOD ;
static const INT32 MAX_LOGGER_COUN T;
static const INT32 MAX_LOGGER_METH OD_COUNT;
static const INT32 MAX_LOG_MESG_CO UNT;
static const INT32 MAX_REG_COUNT;
static const INT32 MAX_FILE_LENGTH ;
};
/////////////////////////////////////////////BLOCK
DEF//////////////////////////////////////////////////////////////
const INT32 FileLogConstant ::REGISTER_LOGG ER = 0x00;
const INT32 FileLogConstant ::REGISTER_METH OD = 0x01;
const INT32 FileLogConstant ::MAX_LOGGER_CO UNT = 64;
const INT32 FileLogConstant ::MAX_LOGGER_ME THOD_COUNT = 128;
const INT32 FileLogConstant ::MAX_LOG_MESG_ COUNT = 128;
const INT32 FileLogConstant ::MAX_REG_COUNT = 16;
const INT32 FileLogConstant ::MAX_FILE_LENG TH = 4 + 4 +
FileLogConstant ::MAX_LOGGER_CO UNT *
(16 + 4 + 64 * FileLogConstant ::MAX_LOGGER_ME THOD_COUNT) + 4 + 4 +
FileLogConstant ::MAX_LOG_MESG_ COUNT * (2 + 2 + 4 + 4 + 256) +
FileLogConstant ::MAX_REG_COUNT * (2 + 2 + 64);
/////////////////////////////////////////////////BLOCK
DEF////////////////////////////////////////////////////////////
class Foo
{
public:
char buffer[FileLogConstant ::MAX_FILE_LENG TH];
};
when BLOCK DEF is put in FileLogConstant .cpp file, the buffer
declaration of class Foo will be compiled with an error. While BLOCK
DEF is put in FileLogConstant .h file, the compiler will generate many
const FileLogConstant ::MAX_FILE_LENG TH already defined errors.
How to define class final constants?