C++基础 有默认参数的函数

默认参数 就是在函数声明的时候需要的时候给赋值了 编程默认的了  有参数就覆盖 

没有必须要传入

函数中有默认值的参数 一定要写到右边——》 右 不然自己体验后果

#include "stdafx.h"
#include <iostream>
#include "stdlib.h"
using namespace std;

float Mess(float a,float=10.1,float=7.7);

int _tmain(int argc, _TCHAR* argv[])
{
	cout<<" Mess(a,b,c) = " << Mess(2.2)<<endl;
	cout<<" Mess(a,b,c) = " << Mess(2.2,20.1)<<endl;
	system("pause");
	return 0;
}

float Mess(float a, float b ,float c)
{
	return a+b+c;
}

发布了279 篇原创文章 · 获赞 43 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/q465162770/article/details/103456380