c++ - 'operator<<' C++ 不匹配
问题描述
我的程序无法运行,我收到一条错误消息:
`error: no match for 'operator<<' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and '<unresolved overloaded function type>')|`
在这cout << address, " ", street << endl;
条线上我使用的是 VS2017,但在中途切换到 CodeBlocks 我有 Windows 10 Pro Ryzen 5 2400G、1060 6gb 16gb ram
这是我的程序:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name, city, state, road, country, street;
int address;
cout << "Enter your: Name\n";
cin >> name;
cout << "Enter your Street\n";
cin >> street;
cout << "Enter your: Address\n";
cin >> address;
cout << "Enter your:\n City\n";
cin >> city;
cout << "Enter your: Province/State\n";
cin >> state;
cout << "Enter your: Country\n";
cin >> country;
//Output
cout << name << endl;
cout << address, " ", street << endl;
cout << city, " ", province, " ", country;
}
提前致谢!
解决方案
你的语法是错误的。您不能使用,
链接参数来cout
喜欢那样。而是这样做:
cout << address << " " << street << endl;
cout << city << " " << province << " " << country;
推荐阅读
- android - 如何获取Android ExifInterface 找不到的EXIF 属性?
- javascript - 如何从 scrollIntoViewOptions 回退以与 Safari 兼容?
- javascript - JS每个函数将第一个值插入为“空”
- reactjs - React 表在第一次渲染时不渲染数据
- amazon-web-services - 对 Flutter 的 AWS 签名者支持
- python - 从时间角度来看,将 PyTorch 模型与 TVM 集成会使情况变得更糟
- php - 尝试访问 null laravel 类型值的数组偏移量
- oop - 方法返回接口
- sql - 更新 db2 中 json 文档中的字段值
- dpdk - L2FWD dpdk 申请结果