0

我试图用我自己的版本覆盖一个类,然后创建一个对该类的超类引用,但我得到一个编译错误。这是我的代码结构

文件:RailExtractionInteractorStyle.h(这是我继承超类 PCLVisualizerInteractor 的子类)

#include<pcl/visualization/interactor_style.h>


class RailExtractionInteractorStyle : public pcl::visualization::PCLVisualizerInteractorStyle
{
public:
    RailExtractionInteractorStyle();
};

文件:RailExtractionInteractor.cpp:

#include "RailExtractionInteractorStyle.h"

RailExtractionInteractorStyle::RailExtractionInteractorStyle()
    : pcl::visualization::PCLVisualizerInteractorStyle()
{
    // just calling super constructor for now
}

文件:CloudPointPicker.hpp(使用 RailExtractionInteractorStyle 类的任意类)

#include "RailExtractionInteractorStyle.h"

template <typename PointT>
class CloudPointPicker {

protected:


    PointCloudTConstPtr cloud_;
    boost::shared_ptr<pcl::visualization::PCLVisualizer> myview_;


    //attempting to write my own interactor
    RailExtractionInteractorStyle* mystyle_;

public:

    CloudPointPicker() {
        *mystyle_ = new RailExtractionInteractorStyle;

    }

CloudPointPicker 构造函数中的语句给了我以下错误:

error: no match for ‘operator=’ in ‘*((CloudPointPicker<pcl::PointXYZ>*)this)->CloudPointPicker<pcl::PointXYZ>::mystyle_ = (operator new(480u), (<statement>, ((RailExtractionInteractorStyle*)<anonymous>)))’

我究竟做错了什么?

4

1 回答 1

0

You have to remove the * at the beginning of this line:

*mystyle_ = new RailExtractionInteractorStyle;

The operator new apply to the pointer directly, you don't need to dereference it.

于 2013-01-18T21:31:33.657 回答