????C++??new
???????????? ???????[ 2014/11/11 11:34:30 ] ????????C++ new ???
????1. New?????
????????ù????new??????????????????????????????????????£?
?????? ???????????
?????? ??????????
?????? ?????????????????
???????????????????????????????????????????????????δ???
1 #include <iostream>
2
3
4 class A {
5 int m_value;
6 public:
7 A(int value) :m_value(value * value){}
8 void Func(){
9 std::cout<< m_value;
10 }
11 };
12
13 int main()
14 {
15 A *aPtr = new A(1);
16 delete *aPtr;
17 system("pause");
18 return 0;
19 }
????????? “A *a = new A(1);” ??????????????£?
????1 A *aPtr = (A*)malloc(sizeof(A)); // ???????????
????2 aPtr->A::A(1); // ???????????
????3 return aPtr; // ????????????
???????????仰?????????????????aPtr?????????????????????new????????????????malloc???????????????????÷???????????????new_handler???????new????????????????????????new???????Щ????????鷳??
?????????? “A *a = new A(1);” ??????windows 7?? Visual Studio 2008????
1 A *aPtr = new A(1);
2 0116140D push 4
3 0116140F call operator new (1161190h) ????//???new?????????
4 01161414 add esp??4
5 01161417 mov dword ptr [ebp-0ECh]??eax
6 0116141D mov dword ptr [ebp-4]??0
7 01161424 cmp dword ptr [ebp-0ECh]??0
8 0116142B je main+72h (1161442h)
9 0116142D push 1
10 0116142F mov ecx??dword ptr [ebp-0ECh]
11 01161435 call A::A (1161019h) ????????????????//???ù????????г????
12 0116143A mov dword ptr [ebp-100h]??eax
13 01161440 jmp main+7Ch (116144Ch)
14 01161442 mov dword ptr [ebp-100h]??0
15 0116144C mov eax??dword ptr [ebp-100h]
16 01161452 mov dword ptr [ebp-0F8h]??eax
17 01161458 mov dword ptr [ebp-4]??0FFFFFFFFh
18 0116145F mov ecx??dword ptr [ebp-0F8h]
19 01161465 mov dword ptr [ebp-14h]??ecx ????????//???????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11