C++里字符串连接出现的问题
cout << "fahr = 150, celsius = ";
输出单个字符串可以实现。
cout << "fahr = 150, celsius = " + "c";
若使用+号连接 会出现错误提示
要是想连接两个或多个字符串
我发现了有两种方式
第一种 开头输入
#include <string>
在第一个字符串前面输入std::string
cout << std::string("fahr = 150, celsius = ") + "c";
原理参考
Error: invalid operands of types ‘const char [35]’ and ‘const char [2]’ to binary ‘operator+’
第二种方法
直接用
cout << "auidhuiah" << "aukduhauk";
用<<连接
over!