Hi,
I have a homework assignment that I just cannot figure out. I would be grateful of any help.

The assignment is:

Create a program which:
Implements a class called Queue: The class should contain an array of maxQ integers.
There should be two constructors:
One that takes no argument creates a Queue object of maxQ=100 values.
One that takes a parameter q and creates a Queue object of maxQ=q values.
Queue should also have:
a function/method add(int) by which a user can add an integer value to a Queue object.
a function/method take() by which a user can read from a Queue object the first integer that was entered into it. After being read the integer should not be in the queue anymore.
In the main():
create a Queue object of maxQ=20
keep on asking the user whether (s)he wants to 1) add integers to the queue; 2) take integers from the queue; 3) exit.
when the user is prompted for the choice above (s)he should also be shown how many integers are currently in the queue.
Suggestions:
You may have 2 values stored inside class Queue:
start: the position of the first element that was entered
end: the position of the last element entered
When an element is added through add(int), end should advance by one. If this brings it past the end of the array, it should pan to the beginning.
When an element is taken through take():
if no element is in the queue, 0 should be returned and nothing else should happen
if the queue is not empty, the first element entered (the one at position start) should be returned, and start should advance by one. If this brings it past the end of the array, it should pan to the beginning.

#include <iostream>

using namespace std;

class Queue {
private:
    int array[maxQ];

That's all the code I've got. How do you declare constructors?
Thanks

This is actually a clear-cut easy to follow assignment. Your instructor did all the thinking for you. There is nothing left up to your imagination; all you have to do is follow directions.

class Queue
{
     public:

     Queue();
     Queue(int& q);
     void add(int);
     void take();

     private:

     int array[100];
};

You will probably end up adding more stuff to this class, like menu() and display() functions for example.. what I outlined for you is the bear minimum required of your assignment.

class Queue
{
     public:
     Queue(){maxQ=100};
     Queue(int& q){maxQ=q};
     void add(int){//add the parameter of this function to ith element of array};
     void take();
     protected:
     int array[100];
};
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.