注:原创不易,转载请务必注明原作者和出处,感谢支持!

一 报错原因

今天遇到了一个之前从未遇到的报错:

error: invalid new-expression of abstract class type 'CurveFittingEdge'

CurveFittingEdge *edge = new CurveFittingEdge(x_data[i])

下面的是有错误的代码片段:

class CurveFittingEdge : public g2o::BaseUnaryEdge<1, double, CurveFittingVertex>
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
CurveFittingEdge(double x) : BaseUnaryEdge(), _x(x) {}
// 计算曲线模型误差
void computeError()
{
const CurveFittingVertex *v = static_cast<const CurveFittingVertex *>(_vertices[0]);
const Eigen::Vector3d abc = v->estimate();
_error(0, 0) = _measurement - std::exp(abc(0, 0) * _x * _x + abc(1, 0) * _x + abc(2, 0));
} virtual bool read(istream &in) {}
virtual bool write(ostream &out) {} public:
double _x; // x值,y值为_measurement
};

报错情况如下图所示。

看到了吗?有一个虚函数virtual bool write(std::ostream &os) const = 0没有被实现,导致CurveFittingEdge仍然是一个abstract class type

在上面的错误代码片段中,原意是想让虚函数read()write()直接留空,但是出错的地方在于,在上述代码中write()函数后面少了一个const!,解决办法,将上面的错误代码片段中的write()改成如下形式即可:

virtual bool write(ostream &out) const {}

invalid new-expression of abstract class type 'CurveFittingEdge'的更多相关文章

  1. C++:Abstract class : invalid abstract return type for member function ‘virtual...’

    #include <iostream> #include <cmath> #include <sstream> using namespace std; class ...

  2. myeclipse中导入js报如下错误Syntax error on token "Invalid Regular Expression Options", no accurate correc

    今天在使用bootstrap的时候引入的js文件出现错误Syntax error on token "Invalid Regular Expression Options", no ...

  3. invalid initialization of non-const reference of type与discards qualifiers

    参数传递          函数参数的传递是初始化语义:用调用者的实参去初始化函数的形参,如果参数是对象,需要调用该类的拷贝构造函数,如果没有显式定义的拷贝构造函数,则执行默认的按成员拷贝      ...

  4. QT编译错误:invalid application of 'sizeof' to incomplete type 'Qt3DRender::QPickEvent'

    执行3D常将中实体的pick操作,结果出现了编译错误:invalid application of 'sizeof' to incomplete type 'Qt3DRender::QPickEven ...

  5. Syntax error on token "Invalid Regular Expression Options", no accurate corr

    今天导入项目一个js文件报这个错 Syntax error on token "Invalid Regular Expression Options", no accurate c ...

  6. js文件报错Syntax error on token "Invalid Regular Expression Options", no accurate correction

    Syntax error on token "Invalid Regular Expression Options", no accurate correction 1.选中报错的 ...

  7. Invalid regular expression flags 错误

    找到写正则表达式的地方,检查是不是写了一个非法的正则表达式. Invalid regular expression flags

  8. invalid application of `sizeof' to incomplete type `char[] '

    在写代码时,我想用extern来关联一个数组,然后利用sizeof计算数组的大小,代码如下: ... extern char a[]; #define b size=(sizeof(a)/sizeof ...

  9. Uncaught SyntaxError: Invalid regular expression flags(看页面源代码)

    Uncaught SyntaxError: Invalid regular expression flags(看页面源代码) 一.总结 js或者jquery方面的错误看页面源代码,一下子错误就很清晰了 ...

随机推荐

  1. 【Day2】2.函数

     视频地址(全部) https://edu.csdn.net/course/detail/26057 课件地址(全部) https://download.csdn.net/download/gentl ...

  2. ListView 一维排布 动态滑动添加新item代码

    protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentV ...

  3. 更新对象sql语句

    可以这么理解,我们以0为临界值,控制  OR 前 或者  OR后面部分的执行,为啥不是大于0作为临界值,因为这是int型主键. 之前我觉得这不就是炫酷嘛,这么些实际场景在哪里?下面来介绍一下实际的应用 ...

  4. PHP通过php-java-bridge调用JAVA的jar包里class类

    正 文:   有的时候我们需要在PHP里调用JAVA平台封装好的jar包里的class类和方法,一般飘易推荐的做法是采用php-java-bridge做桥接,本文就来介绍一下大致的实现方法. 先简单说 ...

  5. eclipse+springboot+tomcat自带的部署

    最近在看微服务,然后整理了两个springboot.但执行都是内部main执行,想着后期应该会用到tomcat,大部分都是说的打成war包,然后部署到tomcat上. war包的方式就不说了,网上很多 ...

  6. Resource ResourceLoader

    DefaultResourceLoader   -- > ResourceLoader 方法 ResourceLoader getResource(String location); Class ...

  7. wcPro--WordCount扩展

    Github:https://github.com/whoNamedCody/wcPro PSP表格 PSP2.1 PSP阶段 预估耗时 (分钟) 实际耗时 (分钟) Planning 计划     ...

  8. CodeForces - 1204E Natasha, Sasha and the Prefix Sums (组合数学,卡特兰数扩展)

    题意:求n个1,m个-1组成的所有序列中,最大前缀之和. 首先引出这样一个问题:使用n个左括号和m个右括号,组成的合法的括号匹配(每个右括号都有对应的左括号和它匹配)的数目是多少? 1.当n=m时,显 ...

  9. 第十一章 前端开发-bootstrap

    11.5.0 bootstrap 11.5.1 bootstrap的介绍和响应式 http://book.luffycity.com/python-book/95-bootstrap/951-boot ...

  10. (转载) Consul 使用手册(感觉比较全了)

    使用consul 介绍 Consul包含多个组件,但是作为一个整体,为你的基础设施提供服务发现和服务配置的工具.他提供以下关键特性: 服务发现 Consul的客户端可用提供一个服务,比如 api 或者 ...