求长方体的体积,长默认为2,用带默认参数的函数来实现
#include<iostream>
using namespace std;
float Volumn_Rectangle(float width,float height,float length = 2)
{
return width*height*length;
}
int main()
{
float length, width, height,V_R;
V_R=Volumn_Rectangle(2,2);
cout<<V_R;
return 0;
}
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/a716c65ab2183f6f81664b17706a51f6.png)