J
Joost Kraaijeveld
Hi,
I want to initialise a const static char array in a class that should be
header only. The header will be included by many clients within the same
program. Ordinary int and char variables I can initialise in the class
declaration. But an array fails, e.g.
class Message
{
public:
static const char majorVersion = 1; // OK
static const char minorVersion = 1; // OK
static const char magicNumber[] = {'1','0','0','1'}; // Not OK
}
results in the following compiler (GCC) error:
error: in-class initialization of static data member ‘const char
Message::magicNumber []’ of incomplete type.
Is this a matter of mere syntax or is this something that cannot be
done? Or is there another way to get the same effect, without resorting
to a cpp file?
TIA
Joost
I want to initialise a const static char array in a class that should be
header only. The header will be included by many clients within the same
program. Ordinary int and char variables I can initialise in the class
declaration. But an array fails, e.g.
class Message
{
public:
static const char majorVersion = 1; // OK
static const char minorVersion = 1; // OK
static const char magicNumber[] = {'1','0','0','1'}; // Not OK
}
results in the following compiler (GCC) error:
error: in-class initialization of static data member ‘const char
Message::magicNumber []’ of incomplete type.
Is this a matter of mere syntax or is this something that cannot be
done? Or is there another way to get the same effect, without resorting
to a cpp file?
TIA
Joost