虚函数sizeof以及简单虚函数表

 1 /* cpp面试题 虚函数指针表的地址 */
 2 
 3 #include<iostream>
 4 
 5 using namespace std;
 6 
 7 class myclass
 8 {
 9 public:
10     virtual void run1()
11     {
12         cout << "run" << endl;
13     }
14 
15     virtual void run2()
16     {
17         cout << "run" << endl;
18     }
19 };
20 
21 void main()
22 {
23 
24     cout << sizeof(myclass) << endl;// 4
25     myclass my1;
26 
27 
28 
29     cin.get();
30 }

 

posted on 2015-06-10 10:42  Dragon-wuxl  阅读(135)  评论(0)    收藏  举报

导航