zoukankan      html  css  js  c++  java
  • default argument given of parameter 的问题

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

    类头文件的声明例如以下:

    void train(std::vector<std::vector<double> >& trainSet, std::vector<int>& labels, const std::string model, double lrate, 
    	std::vector<double>& w , double& b, int maxiter, double delt = 0.0000001 );


    实现代码例如以下:

    <pre name="code" class="cpp">void perceptron::train(std::vector<std::vector<double> >& trainSet, std::vector<int>& labels, const std::string model, double lrate, 
    	std::vector<double>& w , double& b, int maxiter, double delt=0.000001  )
    {
    	
               ....
    
    }

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

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

    void perceptron::train(std::vector<std::vector<double> >& trainSet, std::vector<int>& labels, const std::string model, double lrate, 
    	std::vector<double>& w , double& b, int maxiter, double delt  )
    {
    	
               ....
    
    }

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


  • 相关阅读:
    Oracle使用笔记
    跳转至锚点
    项目中使用到的AOP
    短信验证码接口使用
    阿里人脸识别接口
    java实现网页截图
    java后台接收微信服务号/订阅号消息
    java 实现redis缓存
    redis 常用命令
    被骗了,自己还不知道
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/4030682.html
Copyright © 2011-2022 走看看