代码拉取完成,页面将自动刷新
#include <iostream>
#include <stdio.h>
using namespace std;
class A {
public:
int pub_i1;
int pub_i2;
void pub_foo1() {
cout << "A::prv_i1 addr: " << &prv_i1 << endl;
cout << "A::prv_i2 addr: " << &prv_i2 << endl;
printf("A::prv_foo1() addr: %p\n", (void *)&A::prv_foo1);
printf("A::prv_foo2() addr: %p\n", (void *)&A::prv_foo2);
}
void pub_foo2() {}
virtual void pub_vfoo1() {}
virtual void pub_vfoo2() {}
private:
int prv_i1;
int prv_i2;
void prv_foo1() {}
void prv_foo2() {}
};
class B : public A {
};
int main()
{
A a;
cout << "sizeof A: " << sizeof(A) << endl;
cout << "a addr: " << &a << endl;
cout << "A::pub_i1 addr: " << &a.pub_i1 << endl;
cout << "A::pub_i2 addr: " << &a.pub_i2 << endl;
printf("A::pub_foo1() addr: %p\n", (void *)&A::pub_foo1);
printf("A::pub_foo2() addr: %p\n", (void *)&A::pub_foo2);
printf("A::pub_vfoo1() addr: %p\n", (void *)&A::pub_vfoo1);
printf("A::pub_vfoo2() addr: %p\n", (void *)&A::pub_vfoo2);
a.pub_foo1();
void **__vptr = (void **)&a;
void **virtual_table = (void **)(*__vptr);
printf("virtual table[0]: %p\n", virtual_table[0]);
printf("virtual table[1]: %p\n", virtual_table[1]);
//IT刘小虎
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。