3 ms·
The 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 s
by MaulingMonkey 13y ago
The 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]