You have two variables named
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.
svc_resp variable, declared before the
while loop, as a
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.