c++ - 是否不再需要字符串头文件?
问题描述
所以我现在正在学习 C++,并且在某些时候我看到你“必须”#include <string>
在代码的顶部使用字符串。但是当我运行我的代码时,它在两种情况下都做同样的事情。所以是真的需要使用吗?
#include <iostream>
using namespace std;
int main()
{
string fullName;
cout << "Type your full name: ";
getline(cin, fullName);
cout << "Your name is: " << fullName;
}
解决方案
一些编译器实现在标头<string>
中包含标头<iostream>
。
但是你不能依赖这个。
推荐阅读
- html - 电子邮件输入字段宽度仅随内联样式更改
- reactjs - 使用图像作为带有 react-select 的图标
- angular - 是否可以将 BehaviorSubject 转换为数组流?
- apache-camel - 如何在 quarkus camel 中“直接”使用 Apache Camel
- typescript - 如何在 Angular 8 中生成动态反应形式
- angular - Angular Material Table 刷新一次数据,然后停止刷新数据
- c# - 如何为 Xamarin.Android 实现证书透明度
- python - Python selenium 找不到点击按钮
- java - 更新操作在 jsp/servlet/mysql 中无法正常工作
- swift - 无法使用“字符串”类型的索引为“字符串”类型的值下标 Swift 错误