Created
February 8, 2018 14:48
-
-
Save kekyo/0866c50ee98a49343ed2a948ec4b1f55 to your computer and use it in GitHub Desktop.
Thunk adjuster test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ConsoleApplication1.cpp : Defines the entry point for the console application. | |
// | |
#include "stdafx.h" | |
class IBase | |
{ | |
public: | |
virtual int Method1(int a, int b) = 0; | |
virtual int Method2(int a, int b) = 0; | |
virtual int Method3(int a, int b) = 0; | |
}; | |
class IDerived1 : public IBase | |
{ | |
public: | |
virtual int Method4(int a, int b) = 0; | |
virtual int Method5(int a, int b) = 0; | |
virtual int Method6(int a, int b) = 0; | |
}; | |
class IDerived2 : public IBase | |
{ | |
public: | |
virtual int Method4(int a, int b) = 0; | |
virtual int Method7(int a, int b) = 0; | |
virtual int Method8(int a, int b) = 0; | |
virtual int Method9(int a, int b) = 0; | |
}; | |
class Impl : public IDerived1, public IDerived2 | |
{ | |
public: | |
virtual int Method1(int a, int b) | |
{ | |
return a + b + 1; | |
} | |
virtual int Method2(int a, int b) | |
{ | |
return a + b + 2; | |
} | |
virtual int Method3(int a, int b) | |
{ | |
return a + b + 3; | |
} | |
virtual int Method4(int a, int b) | |
{ | |
printf("this=%p\n", this); | |
return a + b + 4; | |
} | |
virtual int Method5(int a, int b) | |
{ | |
return a + b + 5; | |
} | |
virtual int Method6(int a, int b) | |
{ | |
return a + b + 6; | |
} | |
virtual int Method7(int a, int b) | |
{ | |
return a + b + 7; | |
} | |
virtual int Method8(int a, int b) | |
{ | |
return a + b + 8; | |
} | |
virtual int Method9(int a, int b) | |
{ | |
return a + b + 9; | |
} | |
}; | |
int main() | |
{ | |
Impl* impl = new Impl(); | |
IDerived1* derived1 = impl; | |
IDerived2* derived2 = impl; | |
printf("impl=%p\n", impl); | |
printf("derived1=%p\n", derived1); | |
printf("derived2=%p\n", derived2); | |
auto r0 = impl->Method4(1, 2); | |
auto r1 = derived1->Method4(1, 2); | |
auto r2 = derived2->Method4(1, 2); | |
return 0; | |
} | |
Author
kekyo
commented
Feb 8, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment