Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
#include "Queue.h"
using namespace std;
int main() {

	int number;
	int size;
	cout << "Enter size of queue"; 
	cin >> size;
	Queue q1(size);

	for (int i = 0; i < size; i++) {
		cout << "Enter series of number \n";
		cin >> number;

	cout << "The correct order is \n";
	cout << "The reversed order is ";
	while (stk.empty()==false) {;

	return 0;

void Queue::display() {
	cout << "All value of queue are";
	if (!isEmpty()) {
		for (int i = front; i <= rear;i++) {
			cout << arr[i];

		cout << endl;

What I have tried:

I have a problem in display function as it print out garbage value I do not know why??
for instance it is queue implementation I have implemeneted it using array in class with header and cpp file but I have uploaded the code of the main and display fucntion
I have copied code of display function from cpp file just for view
If anyone know a solution it will be apperciated.
Updated 10-Mar-23 7:51am
jeron1 10-Mar-23 13:33pm    
You're probably going to have to add the implementation of the queue class to the original post, use the green 'Improve question' option.

1 solution

I have copied code of display function from cpp file just for view

You need to learn extremly quickly the variables are the glue between different parts of a program.
First, you store data in q1 and stk, then you try to display the data by using arr. How do you think, the program will make the link between those variable ?
Where is the magic that move the data between variables?
Share this answer
Noran Azab 10-Mar-23 13:54pm    
this is not the problem for sure I have declared variable arr but I did not upload the full implmentation.
Patrice T 10-Mar-23 15:39pm    
Try to build a shorter implementation for this problem.
Nobody will guess what you didn't shown us.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900