3_16.cpp

来自「C++案例教程源代码」· C++ 代码 · 共 13 行

CPP
13
字号
#include <iostream>
using namespace std;
int CalVol(int length, int width = 2, int height = 3);	// 带有默认形参值的函数声明
void main()
{	int x = 10, y = 11, z = 12;
	cout << "Volume of the box is: " ;	cout << CalVol(x, y, z) << endl;
	cout << "Volume of the box is: " ;	cout << CalVol(x, y) << endl;
	cout << "Volume of the box is: " ;	cout << CalVol(x) << endl;
	cout << "Volume of the box is: ";	cout << CalVol(x, 100) << endl;
	cout << "Volume of the box is: ";	cout << CalVol(100, 100, 100) << endl;
}
int CalVol(int length, int width, int height){return length * width * height;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?