gpt4 book ai didi

c++ - cout 打印字符串变量无法通过构建

转载 作者:行者123 更新时间:2023-11-30 01:22:16 25 4
gpt4 key购买 nike

谁能帮我找出以下代码无法成功构建的地方:

#include <iostream>

int main(void){

std::string str1("sfsfasfdsdf");
std::cout << str1 << std::endl;
return 1;
}

谢谢。

最佳答案

您必须包含 std::string header :

#include <string>

编辑:根据@ShafikYaghmour 的评论,include iostream 有时会引入 string,但如果您这样做,情况可能并非如此只有发布的代码。

关于c++ - cout 打印字符串变量无法通过构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16696280/

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