gpt4 book ai didi

C++ if语句在字符串上的错误

转载 作者:搜寻专家 更新时间:2023-10-31 00:18:00 25 4
gpt4 key购买 nike

我知道我问这个问题听起来很像新手,但我很好奇为什么在通过字符串的 if 语句使用简单运算符时会出现错误?这是我为产生错误所做的操作:

    void Shift (string updown )
{
if (updown == "hel")
{
//random code
}
}

我的包含将是:

#include <iostream>
#include <fstream>
#include <Windows.h>
using namespace std;

最佳答案

嗯,你知道的,尝试包含 <string> header 。要么写std::string或添加 using std::string在包含之后。

关于C++ if语句在字符串上的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11858089/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com