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

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


  • 相关阅读:
    Best Cow Fences_二分&&DP
    Palindrome_滚动数组&&DP
    Making the Grade_滚动数组&&dp
    BUY LOW, BUY LOWER_最长下降子序列
    Testing the CATCHER_DP
    Best Sequence_DFS&&KMp
    (Your)((Term)((Project)))
    [SOJ] 畅通工程续
    [SOJ] 商人的宣传
    [SOJ] 无路可逃?
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/4030682.html
Copyright © 2011-2022 走看看