今天写了一个类,当中的一个方法用到了默认參数,结果报了  “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 )
{ .... }

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

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

  1. [err]default argument given for parameter 3 of '***'

    err ~/src/helper.cpp: In function ‘cv::Mat align_mean(cv::Mat, cv::Rect, float, float, float, float) ...

  2. C++编译提示 default argument are given of parameter ..

    如果定义一个类的构造函数时,带有默认的入参值,在cpp文件中实现构造函数时,是不能带的!否则就会提示该种类型的编译错误. //.h文件: namespace Ui { class Task; } cl ...

  3. android studio之argument for @notnull parameter 'name'

    1)进入刚安装的Android Studio目录下的bin目录.找到idea.properties文件,用文本编辑器打开.2)在idea.properties文件末尾添加一行: disable.and ...

  4. 【c++】类中带默认参数的函数

    反思两个问题 1. 带默认参数的函数,为何声明.定义不能同时有参数? 2. 带默认参数的函数, 为何带默认参数的参数靠后站? 上程序 #include <iostream> #includ ...

  5. C++编译错误杂记

    目录 2018年12月23日 error: no matching function for call to ××× 2018年12月10日 error: expected ')' before '* ...

  6. C++中函数参数的扩展

    1,C++ 可以看成是一种更好的 C 语言,所以 C++ 会考虑 C 的欠缺部分,然后给  与一些补充和扩展,本节课讲述 C++ 对函数参数的非常重要的扩展: 2,函数参数的默认值: 1,C++ 中可 ...

  7. parameter和argument的区别

    根据网上一些资料,对parameter和argument的区别,做如下的简单说明.1. parameter是指函数定义中参数,而argument指的是函数调用时的实际参数.2. 简略描述为:param ...

  8. parameter/argument

    根据网上一些资料,对parameter和argument的区别,做如下的简单说明.1. parameter是指函数定义中参数,而argument指的是函数调用时的实际参数.2. 简略描述为:param ...

  9. ES6 new syntax of Default Function Parameters

    Default Function Parameters.md Default Function Parameters function getSum(a,b){ a = (a !== undefine ...

随机推荐

  1. SVN冲突解决详解

    在: http://blog.csdn.net/windone0109/article/details/4857044

  2. Preview of Spring-framework :Spring框架的预习和自我整理

    Spring简介 - 预习的自我整理 1. What's Spring? Spring是一个从实际开发中抽取出来的框架,完成了大量开发中的通用步骤,留给开发者仅仅是与特定应用相关的部分,从而提高了企业 ...

  3. 构建轻量级的Table View注意事项[UIKit]

    參考文章来自objcio站点 一.使用ChildViewController 将Table ViewController作为Child View Controller加入到其它View Control ...

  4. linux下查找某个文件

    参考http://blog.csdn.net/gray13/article/details/6365654 一.通过文件名查找法: 举例说明,假设你忘记了httpd.conf这个文件在系统的哪个目录 ...

  5. Android源代码同步脚本(增加设置线程参数)

    #!/bin/sh #Filename: repo_sync.sh count= ret= ] do #输入参数1,用作同步的线程数 #如果什么参数都不输入,默认线程为4 #usage: ./repo ...

  6. c++宏源证券编程

    1,定义宏功能,作,func(x) = x-1?      最简单的, 假设x = 2则 #define func(x) 1 特化出来x,令 #define func_helper_2 1 #defi ...

  7. OpenVPN-ng,为移动续航的应用层隧道

    VPN,让人觉得它总是做好事的,是逃离监管的途径,其实VPN已经成了逃离监管的唯一代名词.你看,无论是什么技术,IPSec也好,WEB代理也罢,仅仅要是加密了原始信息的技术,都能够叫做VPN,于是乎就 ...

  8. 转: 第二章 IoC Annotation注入

    http://blog.csdn.net/p_3er/article/details/9231307 1.命名空间 使用Annotation的方式,需要在spring的配置文件中配置命名空间.命名空间 ...

  9. 【原创】leetCodeOj --- Majority Element 解题报告(脍炙人口的找n个元素数组中最少重复n/2次的元素)

    题目地址: https://oj.leetcode.com/problems/majority-element/ 题目内容: Given an array of size n, find the ma ...

  10. Android SDK 和 Eclipse ADT 离线安装 教程

    因为google 被限制,就是FQ后,下载的速度依旧非常慢,让人非常崩溃啊,所以这里就分享一下离线安装android SDK 和eclipse ADT 离线安装方法. 安装之前首先已经确保java s ...