was not declared in this scope"在C++中使用模板和继承-6ren"> was not declared in this scope"在C++中使用模板和继承-我正在使用 PCL(点云库)。我创建了一个继承自 PCL 模板类 (pcl::SpinImageEstimation) 的类 (myPCL_SI)。我创建了另一个普通类 (myPCL),它创建了一个 -6ren">
gpt4 book ai didi

c++ - " was not declared in this scope"在C++中使用模板和继承

转载 作者:太空宇宙 更新时间:2023-11-04 11:42:06 25 4
gpt4 key购买 nike

我正在使用 PCL(点云库)。我创建了一个继承自 PCL 模板类 (pcl::SpinImageEstimation) 的类 (myPCL_SI)。我创建了另一个普通类 (myPCL),它创建了一个 myPCL_SI 对象。

我这样做是因为我需要从 pcl::SpinIMageEstimation 访问 protected 方法。如果有人知道更好的解决方案,请告诉我。

好的,我的问题是当我尝试创建一个 myPCL_SI 对象时,编译器给我这个错误:

error: ‘spinImage’ was not declared in this scope
error: template argument 1 is invalid
error: template argument 3 is invalid

我的代码是这样的:

myPCL 类(只有我的方法)

void myPCL::calcSpinImage(){

myPCL_SI<pcl::PointXYZ, pcl::Normal, pcl::Histogram<153>> spinImage;

// doing more things...
}

myPCL_SI 类(标题)

#ifndef MYPCL_SI_H
#define MYPCL_SI_H

// a lot of includes...

using namespace pcl;

template <typename PointInT, typename PointNT, typename PointOutT>
class myPCL_SI : public SpinImageEstimation<PointInT, PointNT, PointOutT>
{
public:
myPCL_SI();
void compute(PointCloud<PointXYZ>::Ptr cloud);

};

#include "mypcl_si.cpp"

#endif // MYPCL_SI_H

myPCL_SI 类(实现)

template <typename PointInT, typename PointNT, typename PointOutT>
myPCL_SI<PointInT, PointNT, PointOutT>::myPCL_SI()
{

}

非常感谢! :D

最佳答案

如果您使用的是较旧的编译器,则在 153 之后的两个 >>> 之间需要一个空格。

参见 Template within template: why "`>>' should be `> >' within a nested template argument list"

关于c++ - "<varName> was not declared in this scope"在C++中使用模板和继承,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21000087/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com