一、初始化
string类有8种初始化方式:
char temp[]="abcdefghigklmn";
序号 | 用法 | 输出 |
---|---|---|
1 | string one("Hello Kitty!"); | Hello Kitty! |
2 | string two(3,'\(');|\)\[| |3|string three(one);|Hello Kitty!| |4|string four=two+three;|\]$Hello Kitty! | |
5 | string five(five,4); | abcd |
6 | string six(temp+2,temp+6); | cdef |
7(1) | string seven1(&six[1]); | def |
7(2) | string seven2(&six[1],&six[3]); | de |
8 | string eight(six,1,3); | de |