首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

【C++&Java】结构函数的调用点

2013-11-08 
【C++&Java】构造函数的调用点//Tree.javapublic class Tree{public Tree( int i){System. out.println(i)}

【C++&Java】构造函数的调用点
//Tree.javapublic class Tree{ public Tree( int i) { System. out.println(i); } }//Test.javapublic class Test{ /** * @param args */ public static void main(String[] args) { Tree tree = new Tree(1); }}//Test.class// access flags 9 public static main([Ljava/lang/String;)V L0 (0) LINENUMBER 11 L0 NEW com/Tree //执行 new一个Tree实例的操作 DUP ICONST_1 INVOKESPECIAL com/Tree.<init>(I)V //编译器插入一条指令:调用Tree的构造函数,并有参数1传入 ASTORE 1 L1 (6) LINENUMBER 13 L1 RETURN L2 (8) LOCALVARIABLE args [Ljava/lang/String; L0 L2 0 LOCALVARIABLE tree Lcom/Tree; L1 L2 1 MAXSTACK = 3 MAXLOCALS = 2}?
#include <iostream>using namespace std;class Xsd{int i;public:Xsd();};Xsd::Xsd(){cout<<"hello xsd"<<endl;}int main(){Xsd* a = new Xsd();return 0;}//main.s__ZN3XsdC2Ev:LFB964:pushl %ebpLCFI0:movl %esp, %ebpLCFI1:subl $24, %espLCFI2: //chentao:执行cout输出movl $LC0, 4(%esp)movl $__ZSt4cout, (%esp)call __ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKcmovl $__ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_, 4(%esp)movl %eax, (%esp)call __ZNSolsEPFRSoS_EleaveLCFI3:retLFE964:.globl __ZN3XsdC1Ev.def __ZN3XsdC1Ev; .scl 2; .type 32; .endef.set __ZN3XsdC1Ev,__ZN3XsdC2Ev.def ___main; .scl 2; .type 32; .endef.globl _main.def _main; .scl 2; .type 32; .endef_main:LFB966:pushl %ebpLCFI4:movl %esp, %ebpLCFI5:andl $-16, %espLCFI6:pushl %esiLCFI7:pushl %ebxLCFI8:subl $40, %espLCFI9:call ___mainmovl $4, (%esp)LEHB0:call __Znwj //chentao: new Xsd()LEHE0:movl %eax, %ebxmovl %ebx, %eaxmovl %eax, (%esp)LEHB1:call __ZN3XsdC1Ev //chentao:插入调用构造函数LEHE1:movl %ebx, 28(%esp)movl $0, %eaxaddl $40, %esppopl %ebxLCFI10:popl %esiLCFI11:movl %ebp, %espLCFI12:popl %ebpLCFI13:ret

?

热点排行