invalid new-expression of abstract class type 'CurveFittingEdge'
注:原创不易,转载请务必注明原作者和出处,感谢支持!
一 报错原因
今天遇到了一个之前从未遇到的报错:
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'的更多相关文章
- C++:Abstract class : invalid abstract return type for member function ‘virtual...’
#include <iostream> #include <cmath> #include <sstream> using namespace std; class ...
- myeclipse中导入js报如下错误Syntax error on token "Invalid Regular Expression Options", no accurate correc
今天在使用bootstrap的时候引入的js文件出现错误Syntax error on token "Invalid Regular Expression Options", no ...
- invalid initialization of non-const reference of type与discards qualifiers
参数传递 函数参数的传递是初始化语义:用调用者的实参去初始化函数的形参,如果参数是对象,需要调用该类的拷贝构造函数,如果没有显式定义的拷贝构造函数,则执行默认的按成员拷贝 ...
- QT编译错误:invalid application of 'sizeof' to incomplete type 'Qt3DRender::QPickEvent'
执行3D常将中实体的pick操作,结果出现了编译错误:invalid application of 'sizeof' to incomplete type 'Qt3DRender::QPickEven ...
- Syntax error on token "Invalid Regular Expression Options", no accurate corr
今天导入项目一个js文件报这个错 Syntax error on token "Invalid Regular Expression Options", no accurate c ...
- js文件报错Syntax error on token "Invalid Regular Expression Options", no accurate correction
Syntax error on token "Invalid Regular Expression Options", no accurate correction 1.选中报错的 ...
- Invalid regular expression flags 错误
找到写正则表达式的地方,检查是不是写了一个非法的正则表达式. Invalid regular expression flags
- invalid application of `sizeof' to incomplete type `char[] '
在写代码时,我想用extern来关联一个数组,然后利用sizeof计算数组的大小,代码如下: ... extern char a[]; #define b size=(sizeof(a)/sizeof ...
- Uncaught SyntaxError: Invalid regular expression flags(看页面源代码)
Uncaught SyntaxError: Invalid regular expression flags(看页面源代码) 一.总结 js或者jquery方面的错误看页面源代码,一下子错误就很清晰了 ...
随机推荐
- idea中安装git后,代码颜色代表的含义
idea中安装git以后,代码文件出现了不同的颜色 它们分别表示的含义: 绿色,已经加入控制暂未提交 红色,未加入版本控制 蓝色,加入,已提交,有改动 白色,加入,已提交,无改动 灰色:版本控制已忽略 ...
- head pose estimation
opencv:帖子中介绍了算法原理和opencv估计姿态的代码 https://www.learnopencv.com/head-pose-estimation-using-opencv-and-dl ...
- Eclispe造成的tomcat占用端口 无法启动 强制终止进程 转载
很多时候运行tomcat 的时候总是会提示tomcat 的端口被占用 但是任务管理器里面还找不到是哪个端口被占用了 因此很多人就重新配置tomcat 或者去修改tomcat的端口号 ,其实这么做太麻 ...
- python自动生成excel(xlwt库)
下面代码使用web.py框架,其他框架都大同小异. # coding: utf- import web import json import datetime import xlwt import S ...
- Centos7添加密码安全策略
设置密码中至少包含一个小写字符,执行命令:# authconfig --enablereqlower --update查看设置:# grep "^lcredit" /etc/sec ...
- [ZOJ 3610] Yet Another Story of Rock-paper-scissors
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4713 题目很水,但是注意,越是简单的题目越应该关注细节,比如说输出上 ...
- cubase 的 CC控制器使用
- PLSQL功能一览(1/2)
用了Oracle几年了,除了PLSQL几乎就没用过别的工具.临时起义想看看PLSQL有哪些功能是我平时没注意的,别是一直有好办法,我却用着笨办法. 本文针对PLSQL12.0.7 1.登录以后使用My ...
- YII2.0.12兼容PHP7.2版本升级
YII2.0.12兼容PHP7.2版本升级 报错信息: FastCGI sent in stderr: "PHP message: PHP Fatal error: Cannot use ...
- keil中使用Astyle格式化你的代码的方法-keil4 keil5通用
简介:在给RTT 提交代码,需要符合RT-Thread 的代码规范,本文简单介绍如何使用Astyle 格式化为符合RTT要求的代码风格. 关于Astyle Astyle 的全称是Artistic St ...