
定义一个string str 然后 str.append(参数)参数只能接受哪些类型?
2个回答
展开全部
append函数是向string 的后面追加字符或字符串。
(1)向string 的后面加C-string
basic_string& append( const value_type* _Ptr );
string s ( "Hello " ); // s=”Hello ”
const char *c = "Out There ";
s.append ( c ); // s=”Hello Out There”
(2)向string 的后面加C-string 的一部分
basic_string& append( const value_type* _Ptr, size_type _Count );
string s ( "Hello " ); // s=”Hello ”
const char *c = "Out There ";
s.append ( c , 3 ); // s=”Hello Out”
(3)向string 的后面加string(有两种方法)
basic_string& append( const basic_string& _Str );
string s1 ( "Hello " ), s2 ( "Wide " ), s3( "World " );
s1.append ( s2 ); // s1=”Hello Wide”
s1 += s3; // s1=”Hello Wide World”
(4)向string 的后面加string 的一部分 ---A
basic_string& append( const basic_string& _Str, size_type _Off,
size_type _Count );
string s1 ( "Hello " ), s2 ( "Wide World " );
s1.append ( s2 , 5 , 5 ); // s1=”Hello World”
(5)向string 的后面加string 的一部分 ---B
template<class InputIterator> basic_string& append(
InputIterator _First, InputIterator _Last );
string str1f ( "Hello " ), str2f ( "Wide World" );
str1f.append ( str2f.begin ( ) + 5 , str2f.end ( ) );
// s1=”Hello World”
(6)向string 的后面加多个字符
basic_string& append( size_type _Count, value_type _Ch );
string str1e ( "Hello " );
str1e.append ( 4 , '!' ); // s1=”Hello !!!!”
参考:http://www.cppblog.com/Sandywin/archive/2008/01/20/41516.aspx
(1)向string 的后面加C-string
basic_string& append( const value_type* _Ptr );
string s ( "Hello " ); // s=”Hello ”
const char *c = "Out There ";
s.append ( c ); // s=”Hello Out There”
(2)向string 的后面加C-string 的一部分
basic_string& append( const value_type* _Ptr, size_type _Count );
string s ( "Hello " ); // s=”Hello ”
const char *c = "Out There ";
s.append ( c , 3 ); // s=”Hello Out”
(3)向string 的后面加string(有两种方法)
basic_string& append( const basic_string& _Str );
string s1 ( "Hello " ), s2 ( "Wide " ), s3( "World " );
s1.append ( s2 ); // s1=”Hello Wide”
s1 += s3; // s1=”Hello Wide World”
(4)向string 的后面加string 的一部分 ---A
basic_string& append( const basic_string& _Str, size_type _Off,
size_type _Count );
string s1 ( "Hello " ), s2 ( "Wide World " );
s1.append ( s2 , 5 , 5 ); // s1=”Hello World”
(5)向string 的后面加string 的一部分 ---B
template<class InputIterator> basic_string& append(
InputIterator _First, InputIterator _Last );
string str1f ( "Hello " ), str2f ( "Wide World" );
str1f.append ( str2f.begin ( ) + 5 , str2f.end ( ) );
// s1=”Hello World”
(6)向string 的后面加多个字符
basic_string& append( size_type _Count, value_type _Ch );
string str1e ( "Hello " );
str1e.append ( 4 , '!' ); // s1=”Hello !!!!”
参考:http://www.cppblog.com/Sandywin/archive/2008/01/20/41516.aspx
追问
追答
什么意思,你要干嘛,直接判断枚举变量的值不就知道是哪个值了吗
2014-12-03
展开全部
插一下
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |