queue does not hold the updated data

You have two variables named svc_resp in main. The second one (at the bottom of the while loop) will create and briefly own a shared_ptr<A> before it is immediately destroyed. This accounts for the constructed and destructed outputs with the increasing numbers.

The first svc_resp variable, declared before the while loop, as a y of 1 and is re-pushed to your queue every loop.

The fix is simple: remove the type name from the second svc_resp declaration, turning it into an assignment.

svc_resp = std::make_shared<A>(ct++);

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top