错误时,我不包括字符串头文件在c ++中 [英] Error when i do not include string header file in c++

查看:210
本文介绍了错误时,我不包括字符串头文件在c ++中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include<iostream>
#include<string>

using namespace std;
void main(){
string str="abc";
cout<<str;
system("pause");
}

如果我不包括字符串头文件, ><<

我认为错误会在str定义的行。

If i do not include string header file then there is an error at << in line cout<

I thought the error will be at line where str is defined.

推荐答案

库头文件可以包括其他标准库头文件,即使在标准中没有指定。因此,在你的实现中, iostream 头包括 string 头的一些部分, c $ c> std :: string 可用,但 std :: operator 不是。

Standard library headers can include other standard library headers, even if not specified in the standard. So it may be that with your implementation, the iostream header includes some parts of the string header, so that std::string is available but std::operator<<(std::basic_ostream<...>&, const std::basic_string<...>&); is not.

这篇关于错误时,我不包括字符串头文件在c ++中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆