带有默认参数的构造函数参数列表不匹配的问题

类中声明的带有默认参数的构造函数是这样的:

MapPoint(unsigned long id, Vector3d &position, Vector3d &best_viewagl, const Mat &best_descr = Mat());

类外定义的构造函数是这样的:

MapPoint::MapPoint(unsigned long id, Vector3d &position, Vector3d &best_viewagl, const Mat &best_descr)
    : id_(id), coor_(position), best_viewagl_(best_viewagl), best_descr_(best_descr), good_(true), visible_times_(1), matched_times_(1)
{
}

调用构造函数是这样的:

new MapPoint(factory_id_++, Vector3d(0, 0, 0), Vector3d(0, 0, 0)));

然后提示:

图片说明

我就不明白哪里出错了?

没有符合你写的实参的函数,你的实参只写了三个,但是看类的声明应该有四个,所以不匹配。

错误提示显示不全。你检查一下,factory_id是usigned long类型吗?