1
我想有取一个列表作为参数的方法,但这个名单应该有默认值的std ::列表paramerter,这里是什么,我需要一个无效的例子:C++使用默认值
void myFunc(std::list<CString> const & myList = std::list<CString>({"Val1", "Val2", "Val3"}));
当我尝试使用它时,我得到
Error C2143: syntax error: missing ')' before '{'
,你可以检查它是否是空的,初始化那个.. –
你怎么知道这个尝试是无效的?你会得到什么错误? –
它有什么问题?我不知道'CString'是什么,但否则你的方法[似乎很好](http://ideone.com/oT4uR4) – user463035818