Play harder
This commit is contained in:
parent
8ae1c4e9eb
commit
d78b1a852a
1 changed files with 17 additions and 4 deletions
|
@ -5,15 +5,23 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class C
|
||||
{
|
||||
public:
|
||||
C() = default;
|
||||
virtual ~C() = default;
|
||||
|
||||
void foo(int bar)
|
||||
{
|
||||
cout << reinterpret_cast<uintptr_t>(this) << " -> " << bar << endl;
|
||||
printf("%p -> %d\n", this, bar);
|
||||
}
|
||||
virtual void fooo(int bar)
|
||||
{
|
||||
printf("%p -> %d\n", this, bar);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -24,10 +32,15 @@ int main(int argc, char **argv)
|
|||
{
|
||||
C c;
|
||||
cvifptr_t zup = &C::foo;
|
||||
cout << zup << endl;
|
||||
vifptr_t baz = reinterpret_cast<vifptr_t>(zup);
|
||||
cout << baz << endl;
|
||||
void (C::*mfp)(int) = &C::foo;
|
||||
vifptr_t biz = reinterpret_cast<vifptr_t>(c.*mfp);
|
||||
|
||||
printf("%p\n", reinterpret_cast<void *>(baz));
|
||||
printf("%p\n", reinterpret_cast<void *>(biz));
|
||||
(c.*zup)(123);
|
||||
(*baz)(1234, 321);
|
||||
(*baz)(0x1234, 321);
|
||||
(*biz)(0x4321, 432);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue