This compiles:
class Node{
int m = 0;
static unsigned f(){
return 1;
}
public:
static unsigned a;
static unsigned b;
};
unsigned Node::a = sizeof(m); // <= !!!
unsigned Node::b = f(); // <= !!!
int main(){
}
Why? I know sizeof
is not function but still, aren't m
and f()
private?
It is definitely not a bug, because the code compiles on GCC, MSVC, Clang and Intel C++.
Update: Also, note that it is just sizeof(m)
and not sizeof(Node::m)
; same with f()
instead of Node::f()
. (Koenig's lookup?)