// now int main() { ConnectionManager mgr; ClientConnection* client = mgr.connect("localhost"); //do stuff with client return 0; //when mgr is implicitly destructed here, all the client connections are //freed } //similar to asio int main() { ConnectionManager mgr; //in theory then I don't need a pointer, the app can create a //ClientConnection in the stack, the heap, with a smart pointer, whatever. ClientConnection client(mgr, "localhost"); //do stuff with client return 0; //here both client and mgr will be implicitly destructed (client first) }