【问题标题】:error: invalid new-expression of abstract class type ‘gr::zeromq::base_sink_impl’错误:抽象类类型“gr::zeromq::base_sink_impl”的无效新表达式
【发布时间】:2021-01-12 08:11:40
【问题描述】:
namespace gr {
   namespace zeromq {

    class base_impl : public virtual gr::sync_block
    {
    public:
      base_impl(int type, size_t itemsize, size_t vlen, int timeout, bool pass_tags);
      virtual ~base_impl();
      
    protected:
      zmq::context_t  *d_context;
      zmq::socket_t   *d_socket;
      size_t          d_vsize;
      int             d_timeout ;
      bool            d_pass_tags ;
    };

    class base_sink_impl : public base_impl
    {
    public:
      base_sink_impl(int type, size_t itemsize, size_t vlen, char *address, int timeout, bool pass_tags, int hwm);

    protected:
      int send_message(const void *in_buf, const int in_nitems, const uint64_t in_offset);
    };
} // namespace zeromq
}

`main(){

gr::zeromq::base_sink_impl *d_zeromq;

d_zeromq = new gr::zeromq::base_sink_impl(ZMQ_PUSH, sizeof(float), 1, "tcp://127.0.0.1:9098", 100, false, -1);

return 0;
}`

你好! 运行此代码后,出现此错误:

错误:抽象类类型“gr::zeromq::base_sink_impl”的无效新表达式 _sink_impl(ZMQ_PUSH, sizeof(float), 1, "tcp://127.0.0.1:9098", 100, false, -1);

                                                                          ^

我不确定如何解决此错误。我想我弄错了构造函数.... 拜托,任何帮助都会非常感激。谢谢

【问题讨论】:

    标签: constructor virtual


    【解决方案1】:

    我发现错误:超类 gr::sync_block 有一个名为 work 的虚拟方法。 我在 base_impl 类中声明了int work(int, gr_vector_const_void_star&, gr_vector_void_star&); 并编译了。

    不幸的是,我无法运行该项目,因为我似乎必须配置一个 CMakeList.txt 来识别 zmq.hpp。看来我还必须在我的 swig 目录中配置 CMakeList.txt,因为我正在尝试使用 ZeroMQ 做一个 GNURadio OOT 块。

    任何帮助,我真的很感激。

    Pd:如果我解决了,我会在这里发布: GNU Radio OOT block : AttributeError: 'module' object has no attribute 'pthread' (using ZeroMQ sockets)

    【讨论】:

      猜你喜欢
      • 2014-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多