Jin*_*iel 3 c++ arguments default-arguments
我写了下面的课
class worker
{
int action;
int doJob(int type,int time = 0);
public:
int call();
}
Run Code Online (Sandbox Code Playgroud)
功能doJob就像
int worker::doJob(int type,int time = 0)
{
....code here
}
Run Code Online (Sandbox Code Playgroud)
当我编译时,我收到以下错误
error: the default argument for parameter 1 of 'int worker::doJob(int, int)' has not yet been parsed
Run Code Online (Sandbox Code Playgroud)
当然这是默认参数规范的问题.那么原型的问题是什么?
您无需重新定义默认值
int worker::doJob(int type,int time = 0)
可以
int worker::doJob(int type,int time)
因为您不需要多次定义参数.
| 归档时间: |
|
| 查看次数: |
1406 次 |
| 最近记录: |