如何定义固定大小boost循环缓冲区作为类成员?

时间:2021-11-26 04:00:10

According to the boost's tutorial, to define a fixed size circular buffer we can do:

根据boost的教程,要定义一个固定大小的循环缓冲区,我们可以这样做:

boost::circular_buffer <int> aspBuffer(3);

how ever, when I take this as a private class member, error occurs: expected identifier before numeric constant

但是,当我把它作为私有类成员时,会发生错误:数字常量之前的预期标识符

When does this happen and how should I do it correctly? Thanks!

这是什么时候发生的,我该怎么做呢?谢谢!

1 个解决方案

#1


6  

You need to initialize the member in the constructor of your class

您需要在类的构造函数中初始化成员

class example {
  boost::circular_buffer<int> aspBuffer;

  public:
  example() : aspBuffer(3) {}
};

#1


6  

You need to initialize the member in the constructor of your class

您需要在类的构造函数中初始化成员

class example {
  boost::circular_buffer<int> aspBuffer;

  public:
  example() : aspBuffer(3) {}
};