【发布时间】:2020-05-31 20:26:54
【问题描述】:
我正在尝试在 C++ 的派生类中声明指向 std::vector<int> 的指针。该类又是其他类的基类。
我的尝试如下
protected:
std::vector<CustomClass> *mypointer;
但是,当我编译它时,我收到以下错误:
error: no match for ‘operator=’ (operand types are ‘std::vector<int>’ and ‘std::vector<int>*’)
error: no match for ‘operator*’ (operand type is ‘std::vector<int>’)
还有一些其他的操作数不见了。
我很茫然,问题出在哪里。我必须在当前类中实现所有这些功能吗?如果是这样,我为什么要这样做?
对于任何需要更多上下文的人,我想在派生自 CbmStsElement 的类 CbmStsSensor (found here) 中实现该指针。
编辑:一些相关的课程可以在这里CbmStsElement.h和enter link description here找到。
Edit2:整个编译错误日志可以在here找到。
【问题讨论】:
-
Firefox 警告我该网站存在潜在的安全风险。提交问题中的所有相关代码,而不是作为外部网站的链接。
-
您显示的 sn-p 不足以诊断问题。错误消息听起来像是您正在尝试将非指针分配给
mypointer。 -
@John 添加了两个相关文件。
-
@StephenNewell 问题是,我什至没有尝试分配任何东西。只需声明该指针,给定消息就已经发生编译错误。
-
这距离minimal reproducible example 还差得很远。
标签: c++ c++11 pointers vector compiler-errors