I am not new to C++ but I was very surprised that this works:
struct Dummy {
int foo() {
return 1;
}
};
int main(int argc, char** argv) {
Dummy* d = nullptr;
int ret = d->foo();
//ret = 1
return 0;
}
I understand that foo
is per-class and not per-instance but is this a language feature people actually use ? Is there a benefit not having foo
as static
here ?