Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- class A
- {
- public:
- virtual void A1() { printf("A1n"); }
- int a2;
- };
- class B
- {
- public:
- virtual void B1() { printf("B1n"); }
- int b2;
- };
- class C : public A, public B
- {
- public:
- virtual void C1() { printf("C1n"); }
- int c2;
- };
- class D : public C
- {
- public:
- virtual void D1() { printf("D1n"); }
- int d2;
- };
- C *c;
- D *d;
- int main()
- {
- c->A1();
- c->B1();
- c->C1();
- d->A1();
- d->B1();
- d->C1();
- d->D1();
- printf("%d%d%d%d%d%d%dn", c->a2, c->b2, c->c2, d->a2, d->b2, d->c2, d->d2);
- return 0;
- }
- int __cdecl main()
- {
- char v1; // [sp+Ch] [bp-C0h]@1
- memset(&v1, 0xCCu, 0xC0u);
- c->vfptr->A1((A *)c);
- c->vfptr->B1(&c->vfptr);
- c->vfptr[1].A1((A *)c);
- d->vfptr->A1((A *)d);
- d->vfptr->B1(&d->vfptr);
- d->vfptr[1].A1((A *)d);
- d->vfptr[2].A1((A *)d);
- _printf("%d%d%d%d%d%d%dn", c->a2, c->b2, c->c2, d->a2, d->b2, d->c2, d->d2);
- return 0;
- }
- struct A
- {
- AVtbl *vfptr;
- int a2;
- };
- struct AVtbl
- {
- void (__thiscall *A1)(A *this);
- };
- struct B
- {
- BVtbl *vfptr;
- int b2;
- };
- struct BVtbl
- {
- void (__thiscall *B1)(B *this);
- };
- struct __cppobj C : A, B
- {
- int c2;
- };
- struct __cppobj D : C
- {
- int d2;
- };
- struct A
- {
- AVtbl *vfptr;
- ABody body;
- };
- struct ABody
- {
- int a2;
- };
- struct AVtbl
- {
- void (__thiscall *A1)(A *this);
- };
- struct B
- {
- BVtbl *vfptr;
- BBody body;
- };
- struct BBody
- {
- int b2;
- };
- struct BVtbl
- {
- void (__thiscall *B1)(B *this);
- };
- struct C
- {
- CVtbl *vfptr;
- CBody body;
- };
- struct __cppobj CBody : ABody
- {
- BVtbl *vfptr_1;
- BBody baseclass_1;
- int c2;
- };
- struct __cppobj CVtbl : AVtbl
- {
- void (__thiscall *C1)(C *this);
- };
- struct D
- {
- DVtbl *vfptr;
- DBody body;
- };
- struct __cppobj DBody : CBody
- {
- int d2;
- };
- struct __cppobj DVtbl : CVtbl
- {
- void (__thiscall *D1)(D *this);
- };
- int __cdecl main()
- {
- char v1; // [sp+Ch] [bp-C0h]@1
- memset(&v1, 0xCCu, 0xC0u);
- c->vfptr->A1((A *)c);
- c->body.vfptr_1->B1(&c->body.vfptr_1);
- c->vfptr->C1(c);
- d->vfptr->A1((A *)d);
- d->body.vfptr_1->B1(&d->body.vfptr_1);
- d->vfptr->C1((C *)d);
- d->vfptr->D1(d);
- _printf(
- "%d%d%d%d%d%d%dn",
- c->body.a2,
- c->body.baseclass_1.b2,
- c->body.c2,
- d->body.a2,
- d->body.baseclass_1.b2,
- d->body.c2,
- d->body.d2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement