default argument given of parameter 的问题

今天写了一个类,其中的一个方法用到了默认参数,结果报了  “default argument given of parameter 的问题 ” 错误。

类头文件的声明如下:

[cpp]  view plain  copy
  1. void train(std::vector<std::vector<double> >& trainSet, std::vector<int>& labels, const std::string model, double lrate,   
  2.     std::vector<double>& w , double& b, int maxiter, double delt = 0.0000001 );  


实现代码如下:

[cpp]  view plain  copy
  1. <pre name="code" class="cpp">void perceptron::train(std::vector<std::vector<double> >& trainSet, std::vector<int>& labels, const std::string model, double lrate,   
  2.     std::vector<double>& w , double& b, int maxiter, double delt=0.000001  )  
  3. {  
  4.       
  5.            ....  
  6.   
  7. }  

 
经上网查询才知, 
带有默认值参数的函数,在实现的时候,参数上是不能有值的 
 

应该将实现代码中的默认参数去掉,如下

[cpp]  view plain  copy
  1. void perceptron::train(std::vector<std::vector<double> >& trainSet, std::vector<int>& labels, const std::string model, double lrate,   
  2.     std::vector<double>& w , double& b, int maxiter, double delt  )  
  3. {  
  4.       
  5.            ....  
  6.   
  7. }  

此时,就没有这个错误了。  记录一下。

转载:https://blog.csdn.net/chenlei0630/article/details/39393731

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值