Class object queue doesn't provide proper value

In reply to navdeepp5:

Please use code tags making your code easier to read. I have added them for you.

Your problem is you are only constructing one packet class object and storing its class handle into the class variable p2. Then you go through the for loop modifying the same object and pushing the same class handle into the queue. Then all elements of p_q reference the same object.

You need to move the construction of the packet class object inside the first for loop so that each iteration pushes a different packet object handle onto the p_q queue.