【发布时间】:2023-02-26 14:21:52
【问题描述】:
这段代码有什么问题???。编译器显示没有匹配函数调用max(int&, int&, int&, int&)的消息
#include<iostream>
using namespace std;
int main()
{
int a,b,c,d;
cin>> a >> b >> c >>d;
max(a,b,c,d);
return 0;
}
int max(int a,int b,int c,int d)
{
if(a>b && a>c && a>d)
{
return a;
}
else if(b>c && b>d)
{
return b;
}
else if(c>d)
{
return c;
}
else
{
return d;
}
}
【问题讨论】:
-
使用前向声明或在 main 之前定义函数。见 Why can't a function go after Main
标签: c++