C++????????????
???????????? ???????[ 2016/9/21 9:55:13 ] ????????????? C++
?????????????????C??????????????????????о???????鷳??C?????????????????????????????????????????????????????????????????????????????C++?У???????????????????????????????C++?и????????????????????????????????https://github.com/chenyufeng1991/CppString??
?????????????C++?е????????????
????#include <string>
???????????????????????.h??????????C?????е????????
??????1???????????
??????????????кü???????????????????????????????
????string str("chenyufeng"??3);
????cout << str << endl;
????cout ????????????????????3???????μ???????????????che.
????string str2("chenyufeng"??2??3);
????cout << str2 << endl;
????cout ????????????index=2???????3???????μ???????????????eny??
????// = :????????
????str2 = "Robert";
????cout << str2 << endl;
????????????????????????????????????????????”=“?????????Robert.
??????2??swap:????????????????
????// swap:????????????????
????string string1 = "chen";
????string string2 = "yufeng";
????swap(string1?? string2);
????cout << "string1 = " << string1 << ";string2 = " << string2 << endl;
??????????????????????????????????
??????3??+??append ??????????
????// += ??append????β??????????
????string stringOrigin = "chen";
????string stringAppend = "yufeng";
????stringOrigin = stringOrigin + stringAppend;
????cout << "stringOrigin = " << stringOrigin << endl;
????stringOrigin.append("_OK");
????cout << "stringOriginAppend = " << stringOrigin << endl;
???????????????????????????????????????????????+???????????????????????
??????4??insert???????λ?ò????????
????// insert???????position?????????
????string stringInsertOrigin = "chenyufeng";
????stringInsertOrigin.insert(3?? "__");
????cout << "stringInsertOrigin = " << stringInsertOrigin << endl;
?????????????????indx=3λ?ò???__????????????? che__nyufeng.
??????5??erase??clear????????
????// erase: ??????
????string stringEraseOrigin = "chenyufeng";
????stringEraseOrigin.erase();
????cout << "stringEraseOrigin = " << stringEraseOrigin << endl;
????// clear ???????????
????string stringClearOrigin = "chenyufeng";
????stringClearOrigin.clear();
????cout << "stringClearOrigin = " << stringClearOrigin << endl;
???????????????????????????????
??????6??replace???滻?????
????// replace: ?滻??????????posλ??????size??????滻??????“”?????
????string stringReplaceOrigin = "chenyufeng";
????stringReplaceOrigin.replace(3?? 2?? "66");
????cout << "stringReplaceOrigin = " << stringReplaceOrigin << endl;
????????????????????index=3?????2??????滻??”66“?????????che66ufeng.
??????7??==???? =: ??????????С
????C++????????????????????????в???????????????????????????????????С?????????????????????ASCII???????????С????????????????????????????????????????????λ????
// ==??<??>??<=??>=:????????
string stringLeft = "zhen";
string stringRight = "yufeng";
if (stringLeft == stringRight)
{
cout << "equal" << endl;
}
if (stringLeft != stringRight)
{
cout << "not equal" << endl;
}
if (stringLeft < stringRight)
{
cout << "stringLeft < stringRight" << endl;
}
if (stringLeft > stringRight)
{
cout << "stringLeft > stringRight" << endl;
}
??????
???·???
??????????????????
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