64,654
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
class T {
int x;
public:
void test() {
cout << "class test" << endl;
}
};
int main()
{
cout << "test" <<endl;
}
#include <iostream>
using namespace std;
class T {
int x;
public:
T(int x) { this->x=x; }
void test() {
cout << x << endl;
}
};
int main()
{
T t1(10),t2(20);
t1.test();
t2.test();
}
; int main()
;
push ebp
mov ebp,esp
add esp,-8
;
; {
; T t1(10),t2(20);
;
@1:
mov dword ptr [ebp-4],10 //因为是inline函数,所以构造直接优化为变量赋值,这个是t1.x
mov dword ptr [ebp-8],20 //这个是t2.x
;
; t1.test(); //这个也是inline函数,所以是直接调用cout << t1.x << endl; 也就是cout << 10 << endl; 下面的t2同理
;
push dword ptr [ebp-4] //这个是t1.x 也就是10
push offset @std@cout
call @@std@%basic_ostream$c19std@%char_traits$c%%@$blsh$qi
add esp,8
push eax
call @@std@%endl$c19std@%char_traits$c%%$qr42std@%basic_ostream$c19std@%char_traits$c%%$r42std@%basic_ostream$c19std@%char_traits$c%%
pop ecx
;
; t2.test();
;
push dword ptr [ebp-8] //这个是t1.x 也就是20
push offset @std@cout
call @@std@%basic_ostream$c19std@%char_traits$c%%@$blsh$qi
add esp,8
push eax
call @@std@%endl$c19std@%char_traits$c%%$qr42std@%basic_ostream$c19std@%char_traits$c%%$r42std@%basic_ostream$c19std@%char_traits$c%%
pop ecx
xor eax,eax
;
; }
;
没意义,简单去网上看一下就行了,值得你关注的不是这些.