C++?б??????й????????????
???????????? ???????[ 2015/2/25 15:12:16 ] ????????C++ ???й?
????case 5:
????????????????
????????????????????????????????????????????????????????????????λ??????
???????????′???:
????Point x;
????Point y(x);
????????????????Point???? x??y?? m_color???????"Red"?????;
????????????????????????????? m_color????????????????3?????;
?????????????
??????д??????????????;
????????Point????д???????£?
????Point::Point(const Point& y)
????: m_x(y.m_x)?? m_y(y.m_y)
????{
????m_color = new char[strlen(y.m_color) + 1];
????::strcpy(m_color?? y.m_color);
????}
????case 6:
??????????????????????????????????
???????????????????????
????1> ?????????????????????????????????????????????
????Point x(x); // ????;
????????????????????;
????Point x = x; // ????????????????????????!
???????????????????????????????x????????棬??????????????????m_color????????;
???????飬???????????????????????????????????????????????;
????2> ???????????????????????;
????3> ???????????????new????????????(?????????????????????????????????????????????????)
????????????????£?
????const Point& Point::operator =(const Point& rhs)
????{
????// ?????????????
????// ??????ü?????????????????????????COM????????????????????????;
????if (this != &rhs)
????{
????m_x = rhs.m_x;
????m_y = rhs.m_y;
????// ????????????;
????// ?????μ?;
????delete m_color;
????m_color = new char[strlen(rhs.m_color) + 1];
????strcpy(m_color?? rhs.m_color);
????}
????return *this;
????}
???????????const???????????????????????????????????
????(x = y) = z;
????????????????????????????????????£???????const???;
????case 7:
????????nonmodifying?????????????????;
??????νnonmodifying?????????????????????????????????????????????????????????;
?????????????????????????????bool??;
?????????????????(=?? += ??<<=???);
??????????????????????????浽?????????????棬???????????Ч???????????(&);
???????????:
????1> ????static?? ???????????????????洢???;
??????????????ú????????? w = x+y+z;
for example:
// case 7?????????1??static
const Point& Point::operator +(const Point& rhs) const
{
static Point temp;
temp.m_x = this->m_x + rhs.m_x;
temp.m_y = this->m_y + rhs.m_y;
// ?????????????;
delete temp.m_color;
temp.m_color = new char[strlen(this->m_color) + strlen(rhs.m_color) + 1];
sprintf(temp.m_color?? "%s%s"?? this->m_color?? rhs.m_color);
return temp;
}
?????????????????????п????????????????ж??????????????????????????????????????Effective c++ Item 19??
????2> ????????????????;(?e??????????Ч??)
???????????????????????????????????:
Point *temp = new Point;
...
return (*temp);
????????????????????????λ???????????????й?;
const Point Point::operator +(const Point& rhs) const
{
Point temp;
temp.m_x = this->m_x + rhs.m_x;
temp.m_y = this->m_y + rhs.m_y;
// ?????????????;
delete temp.m_color;
temp.m_color = new char[strlen(this->m_color) + strlen(rhs.m_color) + 1];
sprintf(temp.m_color?? "%s%s"?? this->m_color?? rhs.m_color);
return temp;
}
????case 8:
??????y????????????????????麯??;
???????????:
?????????????????????????麯??;
????????????????????????????:
????????????????????;
for example:
Apple is a kind of fruit?? and banana also is;
so someone write such codes:
Fruit *basket[20];
for (int i = 0; i < 10; ++i)
{
basket[i] = new Apple;
// ??????????;
...
}
for (; i < 20; ++i)
{
basket[i] = new Banana;
// ?????????;
...
}
// ???Fruitde?????????????麯????????????????(???Apple??Banana???????????new?????????)
for (i = 0; i < 20; ++i)
{
delete basket[i];
}
????????????!
???????
????1> ???????????????????????????????μ?new????????????????????;?????????????????
??????????????????????麯???????????????;
????2> ???費(fèi)???麯?????????????????????????????????????????????????????????;
????3> ??????????麯??????????????????????????????????????????????;
????4> ??????麯???????????????????????????????????????????????????????????????????????????!
???????????????????????漰???????????????????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 ??????