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

}

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


posted @ 2014-10-17 11:45  mfrbuaa  阅读(2082)  评论(0编辑  收藏  举报