Cocos2d-x??????C++??????
???????????? ???????[ 2015/1/29 14:36:16 ] ????????C++ ??????? ??????
????2??new??delete???
??????malloc??free?????new??delete?????????????C++?????????new?????????????????????????裨?????????????????????棬??????????ù????????????棩?????????ù??????????????
????MyObject *obj = new MyObject();
???????????????????????????????????б??????????????????????г????????
????new??????????????????delete??delete??????????????????????檔???????
????delete obj;
????obj????????obj?????????new??????????????????malloc??????????????delete??????????????obj=NULL????“????”??
??????? ?????????????????б????????????????????????????????????????NULL?????????if????????????????Ч?????????????????????free????delete????????????????????????????????????а???????????????????????“????”??檔???????if?????????????????Ч???“????”????Σ???????????????????????????????????????????NULL?????????“????”???????
???????new??delete??????????????????????????£?
#include <iostream>
using namespace std;
class MyObject
{
public :
MyObject(){
cout << "call constructor." << endl;
}
~MyObject(){
cout << "call destructor." << endl;
}
void initialize(){
cout << "call initialization." << endl;
}
void destroy(){
cout << "call destroy." << endl;
}
};
int main(){
MyObject *obj = new MyObject(); // ????????
//TODO
delete obj;
obj = NULL;
return 0;
}
?????????MyObject???????new??????棬delete?????檔??????л???ù???????????????????н?????????£?
????call constructor.
????call destructor.
??????
???·???
??????????????????
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