The relationship of inline and virtual
2007-01-17 10:57
726 查看
test1:
base.h:class base_c
...{
public:
virtual ~base_c() ...{}
virtual int getkind() ...{return 0;}
};
class derive: public base_c
...{
public:
virtual int getkind() ...{return 1;}
};
derived1.cpp:
#include "base.h"
int f1()
...{
derive* pD1=new derive();
base_c* pB=new base_c();
int nRet=pD1->getkind()+pB->getkind();
delete pD1;
delete pB;
return nRet;
}
derived2.cpp:
#include "base.h"
int f2()
...{
derive* pD2=new derive();
base_c* pB=new base_c();
int nRet=pD2->getkind()+pB->getkind();
delete pD2;
delete pB;
return nRet;
}
> nm derive1.o
00000000 W _._6base_c
00000000 W _._6derive
00000000 W __6base_c
00000000 W __6derive
00000000 ? __EXCEPTION_TABLE__
00000000 ? __FRAME_BEGIN__
U __builtin_delete
U __builtin_new
U __rethrow
U __rtti_si
U __rtti_user
00000000 W __tf6base_c
00000000 W __tf6derive
00000008 C __ti6base_c
0000000c C __ti6derive
00000000 V __vt_6base_c
00000000 V __vt_6derive
00000000 T f1__Fv
00000000 t gcc2_compiled.
00000000 W getkind__6base_c
00000000 W getkind__6derive
> nm derive2.o
00000000 W _._6base_c
00000000 W _._6derive
00000000 W __6base_c
00000000 W __6derive
00000000 ? __EXCEPTION_TABLE__
00000000 ? __FRAME_BEGIN__
U __builtin_delete
U __builtin_new
U __rethrow
U __rtti_si
U __rtti_user
00000000 W __tf6base_c
00000000 W __tf6derive
00000008 C __ti6base_c
0000000c C __ti6derive
00000000 V __vt_6base_c
00000000 V __vt_6derive
00000000 T f2__Fv
00000000 t gcc2_compiled.
00000000 W getkind__6base_c
00000000 W getkind__6derive
test2
base.h:class base_c
...{
public:
virtual ~base_c() ...{}
virtual int getkind();
};
class derive: public base_c
...{
public:
virtual int getkind();
};
base.cpp:
#include "base.h"
int base_c::getkind()
...{
return 0;
}
int derive::getkind()
...{
return 1;
}
> nm base.o
00000000 W _._6base_c
00000000 W _._6derive
00000000 ? __FRAME_BEGIN__
U __builtin_delete
U __rtti_si
U __rtti_user
00000000 W __tf6base_c
00000000 W __tf6derive
00000008 C __ti6base_c
0000000c C __ti6derive
00000000 V __vt_6base_c
00000000 V __vt_6derive
00000000 t gcc2_compiled.
00000000 T getkind__6base_c
00000010 T getkind__6derive
> nm derive1.o
00000000 W __6base_c
00000000 W __6derive
00000000 ? __EXCEPTION_TABLE__
00000000 ? __FRAME_BEGIN__
U __builtin_delete
U __builtin_new
U __rethrow
U __vt_6base_c
U __vt_6derive
00000000 T f1__Fv
00000000 t gcc2_compiled.
> nm derive2.o
00000000 W __6base_c
00000000 W __6derive
00000000 ? __EXCEPTION_TABLE__
00000000 ? __FRAME_BEGIN__
U __builtin_delete
U __builtin_new
U __rethrow
U __vt_6base_c
U __vt_6derive
00000000 T f2__Fv
00000000 t gcc2_compiled.
--------------------------------------------------------------------------------------------------------------------------------
q1: vitual function 一般会被拒绝 inline化,那么的定义在哪里?
q2: complier一般将vtbl放在第一个没有inline的vitual function的定义得编译单元内,如所有的virtual function都inline了,vtbl放在哪里?
相关文章推荐
- My priliminary understanding of the relationship between virtual address and physical memory address
- Count the number of alphabets, spaces, digits and other characters in one line character
- my feelings of removing in japan and effort to forget the old relationship
- Improving the Security and User Experience of your Google Sign In Implementation
- objc[2213]: Class _NSZombie_BSXPCMessage is implemented in both ?? and ??. One of the two will be us
- Teddy's Aspect Weaver Version 0.3 with Great Updating and Fixing, Especially the Implementing of Getting Runtime Method Context Info and Method Arguments in MSIL Level
- A Study of Inline View and Analytic Function
- The implementation of anonymous methods in C# and its consequences
- The mixed programming in terms of matlab and C++
- The run order about Loaded event and OnApplyTemplate in custom control of Silverlight 2 beta 2
- The flow of MVC in Spring -- Part I -- Dispatcher and Controller
- [每日练习] write a function to find the key in a m*n matrix, where each line and column is incremental
- We are already in the process of making 6 connections and the number of simultan
- Effective C++ Item 16 Use the same form in corresponding uses of new and delete
- VMware 12安装CentOS 6.9时出现:The centos disc was not found in any of your drives.Please insert the centos disc and press OK to retry
- 译《Time, Clocks, and the Ordering of Events in a Distributed System》
- How to invoke the method of managed bean and render view in JSF when we are outside the lifecycle of JSF
- Analyzing billions of credit card transactions and serving low-latency insights in the cloud
- High Performance Computing in Science and Engineering ' 05 : Transactions of the High Performance Co
- Win A Free Copy of Packt’s Managing Multimedia and Unstructured Data in the Oracle Database e-book