In docs it's highly recommended not to store pointers on contacts:
Do not keep a reference to the pointers sent to b2ContactListener. Instead make a
deep copy of the contact point data into your own buffer. The example below
shows one way of doing this.
I need some kind of contact list.
Now I store pointers on interesting contacts in BeginContact and remove in EndContact.
If I don't keep pointers, how can I identify contacts?