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

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


  • 相关阅读:
    计算机中丢失MSVCP110.dll
    应用程序无法正常启动0xc000007b
    查看80端口被占用
    重装系统后搭建php环境
    修改、设置root密码
    安装虚拟机时出现The Microsoft Runtime DLL
    linux网络配置
    Java拾遗
    哈希中的那些序问题
    笔记本电脑安装jupyterthemes
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/4030682.html
Copyright © 2011-2022 走看看