ok i have everything done for my program but it says i didnt declare myQ i dont understand some help would be nice

here is the main

#include <iostream>
#include "queue.h"
using namespace std;

int main()
{   Queue myQ;
    int i;

    for(i=0;i<SIZE;i++)
    {   myQ.enqueue(i*2);
    }
    myQ.dequeue();  
    myQ.dequeue();
    cout<<myQ.front()<<myQ.back()<<endl;

    while(!myQ.empty())
    {   cout<<myQ.front()<<" ";
        myQ.dequeue();
    }
    cout<<endl;

return 0;
}

here is the .h file

#include <iostream>
#define SIZE 25
using namespace std;
template <class T>

class Queue
{   public:
        Queue();
        bool enqueue(T);
        bool dequeue();
        bool empty();
        bool full();
        T front();
        int size();
        T back();
        void clear();
    private:
        T arr[SIZE];
        int frontt, backk, cnt;
};

#include "queue.cxx"    

and here is the function file

#include <iostream>
using namespace std;

template <class T>
Queue<T>::Queue()
{   cnt=frontt=backk=0;
    for(int i=0;i<SIZE;i++)
    {   arr[i]=0;
    }
}

template <class T>
bool Queue<T>::enqueue(T item)
{   if(!full())
    {   arr[backk]=item;
        cnt++;
        backk=(backk+1)%SIZE;
        return true;
    }else{
        return false;
    }
}

template <class T>
bool Queue<T>::dequeue()
{   if(!empty())
    {   cnt--;
        frontt=(frontt+1)%SIZE;
        return true;
    }else{
        return false;
    }
}

template <class T>
bool Queue<T>::empty()
{   return cnt==0;
}

template <class T>
bool Queue<T>::full()
{   return cnt==SIZE;
}

template <class T>
T Queue<T>::front()
{   if(!empty())
    {   return arr[frontt];
    }else{
        return false;
    }
}

template <class T>
int Queue<T>::size()
{   return cnt;
}

template <class T>
T Queue<T>::back()
{   if(!empty())
    {   return arr[backk -1];
    }else{
        return -1;
    }
}

template <class T>
void Queue<T>::clear()
{   cnt=backk=frontt=0;
}

Edited 3 Years Ago by pritaeas: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.