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  )
    {
    	
               ....
    
    }

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


  • 相关阅读:
    【Gym
    [matlab工具箱] 曲线拟合Curve Fitting
    数学建模 常用
    “这么多人给我作证,我不怕”
    超星尔雅刷课辅助
    细思《都挺好》
    P5173 传球
    [ICPC 北京 2017 J题]HihoCoder 1636 Pangu and Stones
    CF 1131C Birthday
    CF 634A Island Puzzle
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/4030682.html
Copyright © 2011-2022 走看看