题目描述
1. (单选题)C++代码中使用`string`类型,需要包含哪个头文件?
A、``
B、``
C、``
D、``
2. (单选题)下列哪个语句正确地把字符串str中的`"World"`替换为`"Universe"`?
```cpp
string str = "Hello World!";
```
A、`str.replace("World", "Universe");`
B、`str_replace("World", "Universe", str);`
C、`str.replace("World", 5, "Universe");`
D、`str.replace(str.find("World"), 5, "Universe");`
3. 阅读代码,写出运行结果。
```cpp
#include
#include
using namespace std;
int main() {
string str1="How are you";
str1.erase(3):
cout << str1 << endl;
str1="How are you";
str1.erase (3,5) ;
cout << str1 << endl;
return 0;
}
```