Stack using 2 queues issue

what is the problem in the following code?
#include
using namespace std;
//implementing stack using 2 queues
template
struct queue{
private:
int *arr;
int cs;//shows the current number of elements in the queue
int ms;//shows the maximum number of elements queue hold initiallly
int front;
int rear;
public:
queue(int ds=10){

ms=ds;
cs=0;
front=0;
rear=ms-1;
arr=new int[ms];
}

bool full(){
return cs==ms;
}

void enqueue(t data){
    if(!full()){
rear=(rear+1)%ms;
arr[rear]=data;
cs++;}
}

bool empty(){
return cs==0;
}

void dequeue(){
    if(!empty()){
front=(front+1)%ms;
cs--;}
}


int getfront(){
return arr[front];
}

void display(){
for(int i=front;i<=rear;i++){
    cout<<arr[i]<<"-";}
    cout<<endl<<endl;
    }
    int getcs(){
    return cs;
    }

};

//stack class using 2 queues
template
struct stack{
private:
queue q1;
queue q2;
public:
void push(t data){
q1.enqueue(data);//takes O(1) time
}
bool empty(){
return q1.empty();
}

void pop(){//takes O(N) time
if(!empty()){
    for(int i=0;i<q1.getcs()-1;i++){
        q2.enqueue(q1.getfront());
        q1.dequeue();}
        q1.dequeue();
        for(int i=0;i<q2.getcs();i++){
            q1.enqueue(q2.getfront());
            q2.dequeue();}

        }}

int gettop(){
//pushing n-1 elements to the queue2
for(int i=0;i<q1.getcs()-1;i++){
q2.enqueue(q1.getfront());
q1.dequeue();
}
//storing the top element
t no=q1.getfront();
//popping the top element
q1.dequeue();
//pushing n-1 elements back to queue 1
for(int i=0;i<q2.getcs();i++){
q1.enqueue(q2.getfront());
q2.dequeue();}
//pushing the number back
q1.enqueue(no);
return no;
}
void display(){
q1.display();
}
};

int main(){
stack s;
for(int i=0;i<8;i++)
s.push(i);
s.display();
while(!s.empty())
{

cout<<s.gettop()<<"-";
//s.display();
s.pop();
//s.display();
}

return 0;
}

Hello @Rj.25,

Please share your code using Online Coding Blocks IDE.
The way you have shared it has introduced many syntax errors.
STEPS:

  1. Paste your original code at https://ide.codingblocks.com/
  2. Save it there.
  3. Share the URL generated.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.