C++虚函数表
2016-03-14 21:49
471 查看
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<unordered_map> #include<thread> typedef void(*Fun)(void); using namespace std; class test{ public: virtual void print(void){ cout << "HELLO world1111!" << endl; } virtual void print1(void){ cout << "HELLO world2222!" << endl; } int a; ~test(){ cout << "析构函数" << endl; } const static int rr = 0; }; int main(){ test foo; cout << "虚函数表地址" << (int*)&foo << endl; int* addr = (int*)&foo; Fun pFun1 = (Fun)*((int*)*(int*)(&foo)); pFun1(); Fun pFun2= (Fun)*((int*)*(int*)(&foo)+1); pFun2(); }
<img src="https://img-blog.csdn.net/20160314215002377?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
相关文章推荐
- 算数表达式求值C++实现
- c++上机训练
- 浅析 C++ 调用 Python 模块
- C++学习笔记第二周(极客班)
- C++第一次上机实验--(2)
- 文章标题
- C语言文件读写操作中缓冲区问题和setbuf函数详解
- C++ 类型转换
- C语言可变参简介
- C++中值传递、指针传递、引用传递的总结
- c++引用和指针,不为人知的秘密。
- 学习C++的真实经历
- C 语言基础(三)
- 【C/C++语法】Chapter 1
- 2015级C++第3周实践项目
- <<Effective C++>>读书笔记(二)
- iOSDay07之C语言指针
- C++11 现代C++风格的新元素--简介
- c++第二次实验
- c++析构函数为什么要为虚函数