Receive compiler error "cannot declare variable ‘cs’ to be of abstract type" with own template class (baseClass=Features)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Receive compiler error "cannot declare variable ‘cs’ to be of abstract type" with own template class (baseClass=Features)

Hi there,
I want to write my own PCL class and for this I have derived my class from :pcl:Features class.
When I try to create an object of my class I get this error and I cannot for the live of it figure out what it means.

/home/.../PCL_SANDBOX/sandbox_main.cpp:85: error: cannot declare variable ‘cs’ to be of abstract type ‘CloudSubtractor<pcl::PointXYZI, pcl::PointXYZI>’
   CloudSubtractor<PointT,PointT> cs;
i have a typedef in my main.cpp using typedef pcl::PointXYZI PointT;
I want to create the object as like that;

CloudSubtractor<PointT,PointT> cs;  // this is where the error happens

My template class header is like that. Cpp is not used in the case of a template class (as far as I learned so far):

#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/features/feature.h>

template <typename PointInT, typename PointOutT>
class CloudSubtractor: public pcl::Feature<PointInT, PointOutT> 

    typedef boost::shared_ptr< CloudSubtractor<PointInT, PointOutT> > Ptr;
    typedef boost::shared_ptr< const CloudSubtractor<PointInT, PointOutT> > ConstPtr;
    typedef typename pcl::Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut;
    typedef typename pcl::Feature<PointInT, PointOutT>::PointCloudConstPtr PointCloudConstPtr;

      using pcl::Feature<PointInT, PointOutT>::feature_name_;
      using pcl::Feature<PointInT, PointOutT>::getClassName;
      using pcl::Feature<PointInT, PointOutT>::indices_;
      using pcl::Feature<PointInT, PointOutT>::input_;
      using pcl::Feature<PointInT, PointOutT>::k_;
      using pcl::Feature<PointInT, PointOutT>::search_radius_;
      using pcl::Feature<PointInT, PointOutT>::search_parameter_;

    CloudSubtractor () :
          pointIncrement_ (0.25)
            feature_name_ = "CloudSubtractor";


    inline void setPointIncrement(float inc) {pointIncrement_ = inc;}
    inline float getPointIncrement() {return pointIncrement_;}
    void applyDummyFunction(typename pcl::PointCloud<PointInT>::Ptr cloud_out);

    virtual ~CloudSubtractor ()


    /** \brief The grid spacing in x,yz, direction. Smaller values lead to to larger and denser point clouds (default: 0.25). */
    float pointIncrement_;
    /** \brief An input point cloud describing the surface that is to be used for nearest neighbors estimation. */
    using pcl::Feature<PointInT,PointOutT>::surface_;

template<typename PointInT, typename PointOutT>
void CloudSubtractor<PointInT, PointOutT>::applyDummyFunction(typename pcl::PointCloud<PointInT>::Ptr cloud_out)
// off set point cloud by some constant to check that the class is doing something...    
    for (int i=0; i< surface_->size(); ++i){
        cloud_out->points[i].x = surface_->points[i].x + 3;
        cloud_out->points[i].y = surface_->points[i].y + 5;


Can anyone please help me figure out the mistake? I am new to templates and not so experienced in c++ in general. Maybe I made a silly mistake there?