Z
ziman137
Hi all,
I have a question here. What is the rationale behind ISO C++ for
Static Member Definition?
* ISO C++ forbids in-class definition/initialization of non-constant
static member variables.
For example, instead of
class Fred {
public:
Fred();
...
private:
static int N = 0;
};
it must be defined as
int Fred::N = 0;
* However, a static member function can be defined in-class (or,
inline).
What is(are) the problem(s) with in-class static member variable
initialization? Would appreciate any input and help.
Gary
I have a question here. What is the rationale behind ISO C++ for
Static Member Definition?
* ISO C++ forbids in-class definition/initialization of non-constant
static member variables.
For example, instead of
class Fred {
public:
Fred();
...
private:
static int N = 0;
};
it must be defined as
int Fred::N = 0;
* However, a static member function can be defined in-class (or,
inline).
What is(are) the problem(s) with in-class static member variable
initialization? Would appreciate any input and help.
Gary