3 ms·
hmm? you're adding an offset to a pointer (the base of the object), which is still not going to equal 0 even if the offset is 0.
by icedchai 13y ago
hmm? you're adding an offset to a pointer (the base of the object), which is still not going to equal 0 even if the offset is 0.
- MaulingMonkey 13y agoThe C++ standard calls pointers to members... well, pointers to members. I'm not offsetting anything: The compiler is on my behalf. It could create function stubs for all I care, similar to how one might emulate this feature in C#. #include <iostream> struct Foo { int bar; }; int main() { int (Foo::*null_pointer) = nullptr; int (Foo::*first_member_pointer) = &Foo::bar; std::cout << *(std::ptrdiff_t*)&null_pointer << "\n"; std::cout << *(std::ptrdiff_t*)&first_member_pointer << "\n"; } Running this code after compiling it with VS2012 results in, on my machine: -1 0
- deleted 13y ago[deleted]