C++函数的占位参数

#include<iostream>

using namespace std;

/**
 * 带占位参数的函数
 * 格式 返回值类型 函数名(参数类型 参数名, ..., 占位参数类型, ...)
 * 占位参数可以由默认值
 * 格式 返回值类型 函数名(参数类型 参数名, ..., 占位参数类型 = 默认值, ...)
 */
void func(int a, int = 10){
    cout << "function 'func' is called!" << endl;
}

int main() {
//    func(10, 10);
    func(10, 10);
    system("pause");

    return 0;
}

 

posted @ 2020-08-08 17:02  DNoSay  阅读(731)  评论(0编辑  收藏  举报