A
Allen
I defines FileLogConstant class as following.
class FileLogConstant
{
public:
static const INT32 REGISTER_LOGGER;
static const INT32 REGISTER_METHOD;
static const INT32 MAX_LOGGER_COUNT;
static const INT32 MAX_LOGGER_METHOD_COUNT;
static const INT32 MAX_LOG_MESG_COUNT;
static const INT32 MAX_REG_COUNT;
static const INT32 MAX_FILE_LENGTH;
};
/////////////////////////////////////////////BLOCK
DEF//////////////////////////////////////////////////////////////
const INT32 FileLogConstant::REGISTER_LOGGER = 0x00;
const INT32 FileLogConstant::REGISTER_METHOD = 0x01;
const INT32 FileLogConstant::MAX_LOGGER_COUNT = 64;
const INT32 FileLogConstant::MAX_LOGGER_METHOD_COUNT = 128;
const INT32 FileLogConstant::MAX_LOG_MESG_COUNT = 128;
const INT32 FileLogConstant::MAX_REG_COUNT = 16;
const INT32 FileLogConstant::MAX_FILE_LENGTH = 4 + 4 +
FileLogConstant::MAX_LOGGER_COUNT *
(16 + 4 + 64 * FileLogConstant::MAX_LOGGER_METHOD_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_LENGTH];
};
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_LENGTH already defined errors.
How to define class final constants?
class FileLogConstant
{
public:
static const INT32 REGISTER_LOGGER;
static const INT32 REGISTER_METHOD;
static const INT32 MAX_LOGGER_COUNT;
static const INT32 MAX_LOGGER_METHOD_COUNT;
static const INT32 MAX_LOG_MESG_COUNT;
static const INT32 MAX_REG_COUNT;
static const INT32 MAX_FILE_LENGTH;
};
/////////////////////////////////////////////BLOCK
DEF//////////////////////////////////////////////////////////////
const INT32 FileLogConstant::REGISTER_LOGGER = 0x00;
const INT32 FileLogConstant::REGISTER_METHOD = 0x01;
const INT32 FileLogConstant::MAX_LOGGER_COUNT = 64;
const INT32 FileLogConstant::MAX_LOGGER_METHOD_COUNT = 128;
const INT32 FileLogConstant::MAX_LOG_MESG_COUNT = 128;
const INT32 FileLogConstant::MAX_REG_COUNT = 16;
const INT32 FileLogConstant::MAX_FILE_LENGTH = 4 + 4 +
FileLogConstant::MAX_LOGGER_COUNT *
(16 + 4 + 64 * FileLogConstant::MAX_LOGGER_METHOD_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_LENGTH];
};
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_LENGTH already defined errors.
How to define class final constants?