如何修复此代码问题 - 帮助 [英] How can I fix this code problem - HELP

查看:68
本文介绍了如何修复此代码问题 - 帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include



使用命名空间std;



int main(){



string text1 =你好,这是一个字符串;



cout << text1<<结束;





系统(暂停);

}



我尝试了什么:



这是我在Visual Studio中编写的代码。

我试图运行它,然后它对我说:



没有运算符<<匹配这些操作数。

操作数类型是std :: ostream<< std :: string。



我需要帮助!

解决方案

你需要包含< string>

  #include   <   string  > < /跨度>  


#include

using namespace std;

int main() {

string text1 = "Hello, this is a string";

cout << text1 << endl;


system("pause");
}

What I have tried:

This is the code that i wrote in Visual Studio.
I tried to run it, and then it said to me:

no operator "<<" matches these operands.
operand types are std::ostream << std::string.

I Need help!

解决方案

You need to include <string>:

#include<string>


这篇关于如何修复此代码问题 - 帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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