C++编程问题,高手们帮帮忙,很急~

来源:百度知道 编辑:UC知道 时间:2024/06/14 05:49:10
编写一个求长方体体积的函数,CalVol,它有3个参数length(长)、width(宽)和height(高),其中length和width的默认值分别为3和5.2。并进行测试。
---------------------------------------
很急,各位高手帮帮忙,在线等,谢谢了~

/*
* Calculate the Volume of Rectangle
*/
float CalRectVol(float fHeight, float fLength = 3.0f, float fWidth = 5.2f)
{
return (length * width * height);
}

/*
* Template for Calculating the Volume of Rectangle
*/
template <class T>
T CalRectVol(T fHeight, T fLength, T fWidth)
{
return (length * width * height);
}

float CalVol(float height, float length=3, float width=5.2)
{
float res = 0.0;
res = length*width*height;
return res;
}
res就是体积

float CalVol(float height,float length=3,float width=5.2)
{
return length*width*height;
}