第 14 题 想要得到字符串 world
,下面程序横线处应该填入的是( )。
【答案】D
【考纲知识点】字符串及其函数
【解析】insert方法原型为basic_string& insert( size_type index, size_type count, CharT ch );第一个参数表示插入位置,第二个参数表示插入的字符串是什么。
substr方法原型为basic_string substr( size_type pos = 0, size_type count = npos ) const; 第一个参数表示截取子串的开始位置,第二个表示截取长度。
str.substr(5, 5)
从索引 5 截取 5 个字符,原字符串 "HelloC++" 中索引 5 开始为 "C++",但题目要求输出 "world",选项可能存在题目描述冲突。