Can someone explain the reason why bit fields are not allowed as static members of a class? For example, a class defined as:
class A{
public:
A() {}
~A(){}
private:
static int mem :10;
};
int A::mem;
not compiled.
Compiling this class with different compilers: -
1- g ++ throws an error: -
error: static member 'mem' cannot be a bit field
static int mem :10;
error: 'int A :: mem is not a static member of class A data
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 an error: -
'A :: mem' :: illegal storage class
'int A :: mem': republishing member function is not allowed
source
share