Queue implementation using dynamic size array

Hello sir/ma’am, i was trying to implement queue using dynamic size array but there’s some error that i am unable to resolve. according to my code, the output of q1 should be 1 2 3 4 5 9 but it is coming as 0 0 3 4 5 9. Could you please tell me what’s the error in my approach/code??
Sharing my code

hi @priyanshi.agarwal3405
u have given default size of
ds=4 and u r entering 6 element so it will not work
just change ds to upper value like
ds=8
hope you get:)

Sir, I am trying to make dynamic array, so have handled that case i think.

U r making dynamic size array of size ms which is equal to ds
And ur default value of ds is 4 and for q1 u r entering 6 value

Yes sir, that’s exactly what i did in the constructor. But in my push function what i am trying to do is when my existing array size becomes equal to ms i.e. ds in this case, and i have more elements to add , so i am making another dynamic array of size 2cs or say 2ms so that further elements could be added and avoid the loss of elements due to size limitation.

ok
then don’t do
delete []newArr
by this u r deleting the new array from heap
u can delete the old arr
like that
delete []arr
arr=newARR

Okay, got it. Thank you so much sir!!

Good
Mark doubt solved and gave feedback
:slight_smile: