函数必须声明才能使用:
#include
#include
usingnamespace 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;
return0;
}
float area(float a,float b){
return a*b;
}
报错:
main.cpp:Infunction‘int main()’:
main.cpp:11:14: error:‘area’ was not declared inthis scope; did you mean ‘areas’?
11| float areas=area(length,width);
| ^~~~
| areas