Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Intialize circular buffer of Boost Library as member class Linux
Qt 6.11 is out! See what's new in the release blog

Intialize circular buffer of Boost Library as member class Linux

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 2.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aurquiel
    wrote on last edited by aurquiel
    #1

    Hello guys i am struggling trying to initialize the size of a circular buffer as member class

    searching at Google i found another user asking how to do it. The number 3 must be the size of the buffer

    class example {
      boost::circular_buffer<int> aspBuffer;
    
      public:
      example() : aspBuffer(3) {}
    };
    

    i am trying to do the same but not successful, Take a look at my header

    #include <QObject> //To use the class as an Object
    #include <boost/circular_buffer.hpp>
    
    class backend: public QObject
    {
        Q_OBJECT
    
    public:
        //---------------------------PUBLIC VARIABLES BACKEND BEGIN---------------------
        boost::circular_buffer<unsigned char> circular_buff();     //buffer to hold the stream data
        //---------------------------PUBLIC VARIABLES BACKEND END-----------------------
    
        //---------------------------PUBLIC BACKEND FUNCTIONS BEGIN---------------------
        backend() : circular_buff(100);
        //---------------------------PUBLIC BACKEND FUNCTIONS END-----------------------
    

    Compiler shows

    /home/pasante/Escritorio/PIZZA/backend.h:21: error: class ‘backend’ does not have any field named ‘circular_buff’
         backend() : circular_buff(100);
                     ^~~~~~~~~~~~~
    

    I am thinking maybe is a bad linking in the .pro file

    I installed the lib boost through

    sudo apt-get install libboost-all-dev
    

    my .pro file

    #******IMPORTANT LIBRARY OF BOOST LINK********
    LIBS += -lboost_system\
    

    but when i wtire #include <boos the autocomplete show me the path to <boost/circular_buffer.hpp>

    I am not sure what i am doing wrong

    Example of initiliazation as not member class

       #include <boost/circular_buffer.hpp>
    
       int main() {
    
          // Create a circular buffer with a capacity for 3 integers.
          boost::circular_buffer<int> cb(3);
    
       }
    
    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      boost::circular_buffer<unsigned char> circular_buff(); //buffer to hold the stream data

      this is a method declaration, not a member, get rid of () and you are done

      boost::circular_buffer<unsigned char> circular_buff;     //buffer to hold the stream data
      

      P.S.
      don't declare it public, please

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      4
      • A Offline
        A Offline
        aurquiel
        wrote on last edited by
        #3

        Really thanks!!!!!!!!!!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved