函数必须声明才能使用:
#include
#include
using namespace std;
//float area(float a,float b);
int main()
{
float length,width;
length=10.0;
width=5.0;
float areas=area(length,width);
cout << areas <<endl;
return 0;
}
float area(float a,float b){
return a*b;
}
报错:
main.cpp: In function ‘int main()’:
main.cpp:11:14: error: ‘area’ was not declared in this scope; did you mean ‘areas’?
11 | float areas=area(length,width);
| ^~~~
| areas