Why is this C++ code working ?
- by gregseth
Why doesn't the program segfault on the p->info() call?
struct A {
int info() {
retrun (this) ? 1 : -1;
}
};
int main() {
A* p = NULL;
if (p->info() == 1) {
cout << "I'm alive!" << endl;
} else {
cout << "I'm NULL..." << endl;
}
return 0;
}