⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demo_function_default_parameter.cpp

📁 对于一个初涉VC++的人来书
💻 CPP
字号:

#include <iostream.h>
#include <iomanip.h>

int get_volume(int length, int width=2, int height=3);

int main()
{
	int x = 10, y = 12, z = 15;

	cout << "Some box data is " ;
	cout << get_volume(x, y, z) << endl;
	cout << "Some box data is " ;
	cout << get_volume(x, y) << endl;
	cout << "Some box data is " ;
	cout << get_volume(x) << endl;
	cout << "Some box data is ";
	cout << get_volume(x, 7) << endl;
	cout << "Some box data is ";
	cout << get_volume(5, 5, 5) << endl;

	return 0;
}

int get_volume(int length, int width, int height)
{
	cout<<setw(5)<<length<<setw(5)<<width<<setw(5)<<height<<' ';
	return length * width * height;
}

⌨️ 快捷键说明

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