??C++?е?new??delete
???????????? ???????[ 2014/3/5 10:38:23 ] ????????C++ ??????? ????
????C++????????????????????????????C++???????????????????????C++???????????????????????????????????????C++?е?????????????????н????????????????ü??C++????
????1. ????(Function)
????(1) operator new function
????void * ::operator new(size_t); //Global
????void * class-name::operator new(size_t); //Class
??????????C++??operator new function???????????????????????????????????????????operator new??????????????????±????????????????C++?????built-in??????????????????????????????????????operator new?????????????????????????????? ?????????????????????У???????operator new????????????????new?????????????????? ??????????????????operator new?? ??????????operator new??
??????????????????????????к??????????void *????? ??????????size_t??????????C++??????????????????????operator new????????????????void* ???????????????????size_t??????????????????????′????????
????error: ‘operator new’ takes type ‘size_t’ (‘unsigned int’) as first parameter
????????????????????????????????operator new function????????????????????????????Щ?????????????????????????й???????磬?????????????????????????????????к????????????????????????????????????
void * operator new(size_t unSize?? int nLine?? const char * pFunc)
{
prinft("Line: %d?? Func: %s?? allocate %u byte(s)
"?? nLine?? pFunc?? unSize);
return malloc(unSize);
}
????(2) operator delete function
void operator delete( void * );
void operator delete( void *?? size_t );
??????????operator delete function??????operator delete function??????????????????????????????????????????operator delete function??????????????????????????????е?????????????????????????????????????????operator delete function????????????????????????????????????????ó??operator delete function?? ???????????
??????????????????????????????????????????????????????????????????????????????????????????????????С????????????????????????????????????????????????????operator delete function?????????????????????????????????????棨????ο?????????????
????2. ?????(Operator)
????(1) new operator
????[::] new [placement] new-type-name [new-initializer]
????[::] new [placement] ( type-name ) [new-initializer]
????????????’[]‘????????е??????optional????????
??????????new operator????????C++?У?????????????????????new operator???????????new operator?????????棬?????????????????????
????a. ????operator new function??????棨allocate the memory??
????b. ???ù???????call the constructor???????г????
?????????????new operator??????и????????????????
????placement: ???????????operator new function?? placement???????????????????
????type-name: ???????????????????????????(built-in)????????????????????????
????new-initializer: ????????????????????????????????????? ??????????????????????????????????????????????????????????????????????????????????????????????棬??????????????????
??????
???·???
??????????????????
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