fig03_23.cpp
来自「经典vc教程的例子程序」· C++ 代码 · 共 28 行
CPP
28 行
// Fig. 3.23: fig03_23.cpp
// Using default arguments
#include <iostream.h>
int boxVolume( int length = 1, int width = 1, int height = 1 );
int main()
{
cout << "The default box volume is: " << boxVolume()
<< "\n\nThe volume of a box with length 10,\n"
<< "width 1 and height 1 is: " << boxVolume( 10 )
<< "\n\nThe volume of a box with length 10,\n"
<< "width 5 and height 1 is: " << boxVolume( 10, 5 )
<< "\n\nThe volume of a box with length 10,\n"
<< "width 5 and height 2 is: " << boxVolume( 10, 5, 2 )
<< endl;
return 0;
}
// Calculate the volume of a box
int boxVolume( int length, int width, int height )
{
return length * width * height;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?