C++基础解析三十八(3)
C++string类使用、定义
cout<<"judge not equal correct";
else
{
for(int i0;i
{
if(line[i]n1[i])
{
if(il-1)
cout<<"judge not equal error";
}
else
{
cout<<"judge not equal correct";
break;
}
}
}
}
void string::operator (string s1)
{
char n1[100];
strcpy(n1,s1.line);
int m;
mstrlen(n1);
int l;
lstrlen(this->line);
if(l!m)
{
cout<<"judge equal error";
}
else
{
for(int i0;i
{
if(line[i]n1[i])
{
if(il-1)
cout<<"judge equal correct";
}
else
{
cout<<"judge equal error";
break;
}
}
}
}
char string::operator [](int pos)
{
int ipos;
int lstrlen(line);
if(i>-1&&i
{
cout<<"The word at "<
cout<<"s.print():"<
s.print();
cout<
s.turn();
cout<
s.substring(4,12);
cout<
s.insert(5,"abcdefgh");
cout<
s.index("LINE");
cout<
s.index("xyz");
cout<
s.replace("abc","DingTao");
cout<
s.replace("req","dakfj");
cout<
s.strempty();
string s1("abc"),s2("def"),s3("ghi"),s4("abcdefg"),s5("2008");
cout<
cout<<"after s1s1+s2 , s1";
s1s1+s2;
s1.print();
cout<
s1
cout<
s2s4;
cout<
s2!s3;
cout<
s5[3];
}
3COME考试频道为您精心整理,希望对您有所帮助,更多信息在http://www.reader8.com/exam/