Can anyone explain the reason behind not allowing bit fields as static member of a class? For example, a class defined like:
class A{
public:
A() {}
~A(){}
private:
static int mem :10;
};
int A::mem;
doesn't compile.
Compiling this class with different compilers:-
1- g++ throws error:-
error: static member 'mem' cannot be a bit-field
static int mem :10;
error: ‘int A::mem’ is not a static data member of ‘class A’
int A::mem;
2- clang throws error:-
error: static member 'mem' cannot be a bit-field
static int mem :10;
3-Visual Studio 15 throws error:-
'A::mem'::illegal storage class
'int A::mem':member function redeclaration not allowed