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

           ....

}

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

时间: 2024-08-24 05:15:55

default argument given of parameter 的问题的相关文章

default value of template parameter c++

template <typename T, typename CONT = std::vector<T> > = std::vector<T> is the default value of template parameter CONT 原文地址:https://www.cnblogs.com/aspirs/p/11258558.html

C++默认实参

函数默认参数 在C++中,可以为参数指定默认值,C语言是不支持默认参数的,Java也不支持!!! 默认参数的语法与使用:(1)在函数声明或定义时,直接对参数赋值.这就是默认参数:(2)在函数调用时,省略部分或全部参数.这时可以用默认参数来代替. 注意事项: (1)函数默认值只能赋值一次,或者是在声明中,或者是在定义中,如下所示 /*正确*/ #include <iostream> int f(int a=5); int f(int a) { std::cout <<a<<

C++基础2 引用 函数扩展: 默认值 占位符 指针 重载 类:引用类指针 声明实现分开写

[难点]指针引用 [email protected]:~/c++$ cat main.cpp  #include <stdlib.h> #include "iostream" using namespace std; int a = 20; struct Teacher { int age; char name[64]; }; int fun1(struct Teacher ** p) { int ret = 0; if(p == NULL) { ret = -1; ret

实验二:函数重载、模板、简单类的定义和实现

[实验结论] #函数重载 编写重载函数add(),实现对int型,double型,Complex型数据的加法.在main()函数中定义不同类型 数据,调用测试. #include<iostream> using namespace std; struct Complex { double real; double imaginary; }; //函数声明 int add(int a, int b); double add(double a,double b); Complex add(Comp

parameter和argument的区别

在对一个函数写一个注释时,我在考虑到底该用parameter还是用argument来描述其参数呢.根据网上一些资料,对parameter和argument的区别,做如下的简单说明. 1. parameter是指函数定义中参数,而argument指的是函数调用时的实际参数. 2. 简略描述为:parameter=形参(formal parameter), argument=实参(actual parameter). 3. 在不很严格的情况下,现在二者可以混用,一般用argument,而parame

SSIS Parameter用法

Parameters能够在Project Deployment Model下使用,不能在Package Deployment Model使用.在Package Deployment Model下,使用Package Configurations来传递属性值:在Project Deployment Model下,使用Parameters来传递值. 1,Parameters and Package Deployment Model In general, if you are deploying a

干货!一篇文章集合所有Linux基础命令,适合所有菜鸟学习和老手回顾!

1 文件{ ls -rtl # 按时间倒叙列出所有目录和文件 ll -rt touch file # 创建空白文件 rm -rf 目录名 # 不提示删除非空目录(-r:递归删除 -f强制) dos2unix # windows文本转linux文本 unix2dos # linux文本转windows文本 enca filename # 查看编码 安装 yum install -y enca md5sum # 查看md5值 ln 源文件 目标文件 # 硬链接 ln -s 源文件 目标文件 # 符号

Professional C# 6 and .NET Core 1.0 - Chapter 41 ASP.NET MVC

What's In This Chapter? Features of ASP.NET MVC 6 Routing Creating Controllers Creating Views Validating User Inputs Using Filters Working with HTML and Tag Helpers Creating Data-Driven Web Applications Implementing Authentication and Authorization W

Linux Kernel - Debug Guide (Linux内核调试指南 )

http://blog.csdn.net/blizmax6/article/details/6747601 linux内核调试指南 一些前言 作者前言 知识从哪里来 为什么撰写本文档 为什么需要汇编级调试 ***第一部分:基础知识*** 总纲:内核世界的陷阱 源码阅读的陷阱 代码调试的陷阱 原理理解的陷阱 建立调试环境 发行版的选择和安装 安装交叉编译工具 bin工具集的使用 qemu的使用 initrd.img的原理与制作 x86虚拟调试环境的建立 arm虚拟调试环境的建立 arm开发板调试环