How is possible that accessing nullptr works? [duplicate]
问题 This question already has answers here : Why am I able to make a function call using an invalid class pointer (6 answers) Calling class method through NULL class pointer [duplicate] (10 answers) Closed 3 years ago . I have a simple class: class B { public: int getData() { return 3; } }; then, I initialize a pointer to it with nullptr: B *foo{ nullptr }; And then, trying to use it comes the surprise: int t = foo->getData(); and t is now 3. How is that possible without constructing the class?