#include<iostream>
using namespace std;
int main(){
string s="hello";
cout<<s.size()<<endl;
cout<<s.length()<<endl;
string s1;
cout<<s1.empty()<<endl;
string s2("cat");
cout<<s2<<endl;
cout<<s2.empty()<<endl;
//增
string s3="dog";
string s4=s2+s3;
cout<<s4<<endl;
s4.append("123");
cout<<s4<<endl;
//删
s4.erase(6,3);
cout<<s4<<endl;
//改
s4.replace(2,1,"123");
cout<<s4<<endl;
//比
cout<<(s4>s3)<<endl;
string s5("a");
string s6("b");
cout<<(s6>s5)<<endl;
}
string类型的增、删、改、比
最新推荐文章于 2024-07-14 15:36:20 发布