📜  错误:为参数提供默认参数 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:47.610000             🧑  作者: Mango

代码示例1
/*
You are probably redefining the default parameter in the implementation of the function. 
It should only be defined in the function declaration.
*/
//bad (this won't compile)
string Money::asString(bool shortVersion=true){
}

//good (The default parameter is commented out, but you can remove it totally)
string Money::asString(bool shortVersion /*=true*/){
}

//also fine, but maybe less clear as the commented out default parameter is removed
string Money::asString(bool shortVersion){
}