M
Markus Ilmola
Is it really allowed to initialize a static class member by calling a
function?
class foo
{
public:
static int bar;
static float test;
};
int foo::bar = random_number();
float foo::test = read_value_from_config_file();
int main()
{
return 0;
}
It compiles fine with the GNU c++ compiler, but is it really allowed in
the c++ standart? And more importantly is it a safe thing to do?
All examples that a have found from the Internet only use predefined
values like this:
int foo::bar = 4;
float foo::test = 2.0;
function?
class foo
{
public:
static int bar;
static float test;
};
int foo::bar = random_number();
float foo::test = read_value_from_config_file();
int main()
{
return 0;
}
It compiles fine with the GNU c++ compiler, but is it really allowed in
the c++ standart? And more importantly is it a safe thing to do?
All examples that a have found from the Internet only use predefined
values like this:
int foo::bar = 4;
float foo::test = 2.0;