如何解决错误:与“ operator <<”不匹配操作数类型为“ std :: basic_ostream <char>”和“ <未解析的重载函数类型>”
我无法找到错误的解决方案与“操作员
下面是我的代码所产生的错误,
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
std::cin >> t;
while(t--) {
long int i,n,count=0,idx,min=LONG_MAX;
cin >> n;
long int s[n];
for(i = 0; i < n; i++) {
cin >> s[i];
if(s[i] <= min) {
min = s[i];
idx = i;
}
}
cout << "count= " << count << " max= " << max << " idx= " << idx << "\n";
}
}
我遇到类似的错误
prog.cpp: In function ‘int main()’: prog.cpp:19:43: error: no match
for ‘operator<<’ (operand types are ‘std::basic_ostream<char>’ and
‘<unresolved overloaded function type>’)
cout<< "count= "<< count << " max= " << max << " idx= " << idx <<"\n";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
有人可以帮我解决这个问题吗?
解决方法
首先未声明max(第19行)。 之所以给出此错误,是因为它试图调用内置的(算法头文件)std :: max。
我猜你有错字,它是分钟(第19行)而不是最大值:)。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。