Class structure for a queue of variable size and type
<p>I'm more of a hardware person, but the chip design tools I'm using require me to write some C++ code. I am not familiar with object-oriented programming; although I have a good handle on C. What I'm asking is for an explanation of how to structure my class (called <code>cq</code>) to accomplish the task at hand.</p>

<p>I would like to be able to generate a queue of a specified data type and specified size (which should not change after being generated). Ideally, this would be accomplished like this...</p>

<pre><code>my_queue = new cq(uint8_t, 6);
</code></pre>

<p>...which would generate an array (or vector) of six 8-bit unsigned integers.</p>

<p>Then, I would like a method to both insert an element to an end and return the element at the head of the queue as follows.</p>

<pre><code>uint8_t front;
front = my_queue.advance(28);
</code></pre>

<p>What kind of structure do I need to accomplish this? Do I need a template since the data types are variable? Or should I have a generic class and have a class for each data type inherit its structure?</p>

<p>Thank you!</p>

<p><strong>Edit:</strong> using input from the answers below, I've come up with the following:</p>

<pre><code>template &lt;class type&gt;
template &lt;class size&gt;
class CQ {

    private:
        // Allocates a queue with type and size
        // specified by template arguments.
        std::queue&lt;type&gt; cycle_queue(size, 0);

    public:
        // Inserts input to the end of the queue;
        // removes and returns the front element.
        type advance(type in){
            type out = cycle_queue.front();
            cycle_queue.push_back(in);
            cycle_queue.pop_front();
            return out;
        }

}
</code></pre>

<p>My question then becomes... how do I instantiate this in my main C++ program? I tried this, but it did not work:</p>

<pre><code>CQ&lt;uint8_t&gt;&lt;6&gt; my_queue;
my_queue.advance(28);
</code></pre>

<p>Thanks again!</p>
