這裏是我在程序中的C++構造函數問題。「沒有匹配的函數調用」發生在C++的構造函數中
問題發生在這裏,程序中未檢測到的構造函數cyclical_。這裏
pcl::gpu::kinfuLS::KinfuTracker::KinfuTracker
( const Eigen::Vector3f &volume_size, const float shiftingDistance,
int rows, int cols) :
//
// error lies here, no matching function for cyclical_()
//
cyclical_(DISTANCE_THRESHOLD, VOLUME_SIZE, VOLUME_X),
rows_(rows), cols_(cols), global_time_(0), max_icp_distance_(0),
integration_metric_threshold_(0.f),
perform_last_scan_ (false), finished_(false), lost_ (false),
disable_icp_ (false), perform_segmentation_(false)
{
....
}
該cyclical_類是明確定義和引用。它被定義爲下面的一個。完整的原始完整在這裏。 https://github.com/lvzhaoyang/pcl/blob/master/gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/kinfu.h 我在程序中添加了一些參數,但我沒有更改任何與CyclicalBuffer相關的參數。
CyclicalBuffer cyclical_;
CyclicalBuffer object_cyclical_; // another member of type CyclicalBuffer, but the error shows the former one, not this one. Someone say it might affect.
enum { VOLUME_X = 512, VOLUME_Y = 512, VOLUME_Z = 512 };
const float VOLUME_SIZE = 3.0f;
const float DISTANCE_THRESHOLD = 1.5f;
而CyclicalBuffer類的定義如下。原來的這裏是:https://github.com/lvzhaoyang/pcl/blob/master/gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/cyclical_buffer.h這部分我沒有改變任何東西。
namespace pcl
{
namespace gpu
{
namespace kinfuLS
{
class PCL_EXPORTS CyclicalBuffer
{
public:
CyclicalBuffer (const double distance_threshold, const double cube_size = 3.f, const int nb_voxels_per_axis = 512)
{
distance_threshold_ = distance_threshold;
buffer_.volume_size.x = cube_size;
buffer_.volume_size.y = cube_size;
buffer_.volume_size.z = cube_size;
buffer_.voxels_size.x = nb_voxels_per_axis;
buffer_.voxels_size.y = nb_voxels_per_axis;
buffer_.voxels_size.z = nb_voxels_per_axis;
}
CyclicalBuffer (const double distance_threshold, const double volume_size_x, const double volume_size_y, const double volume_size_z, const int nb_voxels_x, const int nb_voxels_y, const int nb_voxels_z)
{
distance_threshold_ = distance_threshold;
buffer_.volume_size.x = volume_size_x;
buffer_.volume_size.y = volume_size_y;
buffer_.volume_size.z = volume_size_z;
buffer_.voxels_size.x = nb_voxels_x;
buffer_.voxels_size.y = nb_voxels_y;
buffer_.voxels_size.z = nb_voxels_z;
}
...
}
}
};
但是,當我編譯問題,給出了這樣的錯誤:
/home/lv/pcl-trunk/gpu/kinfu_large_scale/src/kinfu.cpp: In constructor ‘pcl::gpu::kinfuLS::KinfuTracker::KinfuTracker(const Vector3f&, float, int, int)’:
/home/lv/pcl-trunk/gpu/kinfu_large_scale/src/kinfu.cpp:85:53: error: no matching function for call to ‘pcl::gpu::kinfuLS::CyclicalBuffer::CyclicalBuffer()’
/home/lv/pcl-trunk/gpu/kinfu_large_scale/src/kinfu.cpp:85:53: note: candidates are:
/home/lv/pcl-trunk/gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/cyclical_buffer.h:96:11: note: pcl::gpu::kinfuLS::CyclicalBuffer::CyclicalBuffer(double, double, double, double, int, int, int)
/home/lv/pcl-trunk/gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/cyclical_buffer.h:96:11: note: candidate expects 7 arguments, 0 provided
/home/lv/pcl-trunk/gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/cyclical_buffer.h:75:11: note: pcl::gpu::kinfuLS::CyclicalBuffer::CyclicalBuffer(double, double, int)
/home/lv/pcl-trunk/gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/cyclical_buffer.h:75:11: note: candidate expects 3 arguments, 0 provided
/home/lv/pcl-trunk/gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/cyclical_buffer.h:65:25: note: pcl::gpu::kinfuLS::CyclicalBuffer::CyclicalBuffer(const pcl::gpu::kinfuLS::CyclicalBuffer&)
/home/lv/pcl-trunk/gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/cyclical_buffer.h:65:25: note: candidate expects 1 argument, 0 provided
我不太明白的錯誤候選人預計3個參數,提供0。我想我已經提供了正確的論點數量,並且明確提到了一切。
謝謝你對我的問題的討論。我想我找到了一些線索,但我不知道爲什麼。問題可能在於CyclicalBuffer類型的第二個成員。
CyclicalBuffer cyclical_;
CyclicalBuffer object_cyclical_; // when I comment everything related to this. The error disappears.
這似乎很奇怪。我不知道第二個成員是如何給第一個成員帶來錯誤的。如果這是object_cyclical_未正確構造的問題,爲什麼它會報告cycleical_上的錯誤?爲了確保錯誤報告行85是循環線(DISTANCE_THRESHOLD,VOLUME_SIZE,VOLUME_X)
任何人都可以幫我指出它存在的潛在問題嗎?
CyclicalBuffer在類的末尾有一個缺失的分號 - 您已將它放在名稱空間右花括號上,但我認爲這不是問題 – doctorlove
您可以在此處顯示的代碼中標記第85行嗎?它是你在初始化'cyclical_'的行嗎?有沒有其他的'KinfuTracker'構造函數你沒有顯示? –
我想你需要向我們展示'KinfuTracker'的全部定義(頭部中的部分),因爲你向我們展示的代碼看起來沒有任何問題。 –