c++ - 使用 boost::enable_shared_from_this 时出现不完整的类型错误

标签 c++ shared-ptr

在下一行

class Symbol : public boost::enable_shared_from_this<Symbol> {

我得到错误:

错误:不完整类型的无效使用struct boost::enable_shared_from_this<Symbol> /usr/include/boost/smart_ptr/shared_ptr.hpp:63: 错误:声明 struct boost::enable_shared_from_this<Symbol>

知道为什么我会收到此错误。 Symbol 是一个抽象类(如果重要的话)

最佳答案

哎呀。错误是因为我没有包含 定义 enable_shared_from_this 的 header (这是 boost/enable_shared_from_this.hpp)。

它只是在/usr/include/boost/smart_ptr/shared_ptr.hpp 中声明

关于c++ - 使用 boost::enable_shared_from_this 时出现不完整的类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10509726/

相关文章:

c++ - 如何索引到 C++ shared_ptr/unique_ptr 数组?

c++ - 如果未使用 shared_ptr 定义虚拟析构函数,是否有任何优势

c++ - 使用带有参数的 boost::function 来共享指向派生类的指针

c++ - typedef 具有静态自定义删除器的 shared_ptr 类型,类似于 unique_ptr

C++ 隐式转换和重载函数调用中的歧义

c++ - 'Eigen_solver_traits' 没有命名类型?

c++ - make_shared 和抽象多态性

c++ - 哪个更快 : Stack allocation or Heap allocation

c++ - 生成文件 : Header in different Directory - Error

可以通过 SSH 构建的 C++ IDE