how to create a weld joint when contact bodies touch

This might sound pretty simple. I have created two individual classes for sprites with parent layer properties which I instantiate in the init method of the HelloWorldLayer.mm. How do I create a contact listener in such a way that when these two physics sprites touch a weld joint is created? Please Help.
You might find some useful info here: http://www.iforce2d.net/b2dtut/sticky-projectiles

Original thread: https://box2d.org/forum/viewtopic.php?t=8575