C++?б??????й????????????
???????????? ???????[ 2015/2/25 15:12:16 ] ????????C++ ???й?
????case 3:?????????????????????delete []??
????1>??????????????????????????int??double???????????????????delete??????????
????2>??????????????飬??????????С?????????????delete??array delete??delete []??????????????????У????????????delete m_variety????????????????delete []m_variety;
????3>???????????????????????????飬?????????array delete?????????????????????????????????????????????????????
????free????????????
for example:
#include <iostream>
#include <string>
class Point
{
public:
Point(int x = 0?? int y = 0?? char *col = "Red");
~Point();
protected:
private:
int m_x;
int m_y;
char *m_color;
};
Point::Point(int x?? int y?? char *col)
: m_x(x)?? m_y(y)
{
m_color = new char[strlen(col) + 1];
strcpy(m_color?? col);
}
Point::~Point()
{
delete []m_color;
std::cout << "In the deconstuctor of Point!/n";
}
int main(int argc?? char *argv[])
{
cout << "case 3:/n";
Point *p = new Point[5];
delete p;
// ???????:
// delete []p;
return 0;
}
????case 4:
?????????????????????????鯔?????????????顣
???????????????????????????????????????????delete ????delete [](array delete)??????????????????????????????????????????????delete???.
for example:
// Point???case 3???;
int main(int argc?? char *argv[])
{
cout << "case 4:/n";
Point **pPtrAry = new Point*[10];
// ?????????????????Point????;
int i = 0;
for (; i < 10; ++i)
{
pPtrAry[i] = new Point(i?? i?? "Green");
}
// ?????????????10??Point???????????????????????????????
// ????10*sizeof(Point*) ???????????й?
// (180 = 10*sizeof(Point) + 10* 6; (6= sizeof("Green")))
// delete []pPtrAry;
// ????????:
for (i = 0; i < 10; ++i)
{
delete pPtrAry[i];
}
delete []pPtrAry; // ????delete pPtrAry;
return 0;
}
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
??C++????????????C++ lvalue??rvalueC++11????????C++???????????????C++?е?????????????????C++?????????C++???Windows????λ??C/C++???????????????????JAVA??C??C++??????????c++??python???????????????????????????????C++???????C++?е????????C++????????????????C++ ???????????????C++?????????????????????C++????????????
???·???
??????????????????
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????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????