Your physics code is responsible for detecting collisions.
Once detected, you need to respond to the collision, based on the "types" of A and B.
This is called "double dispatch" and Scott Meyers discusses it in More Effective C++.
Personally I use a more C-style approach to collision response, and use a simple bit-field to denote the type of object.
I look up a collision handler for (A,B) and if its not available, see if there is one for (B,A). Once found, use that one (*).
If there is no special handler set for this type combo, just call a generic response function that pushes the colliding objects apart with contact joint.
This way, you can define a handler for (barrel, player) and another one for (barrel, barrel) for instance. A handler for (player, powerup) would typically remove the powerup without affecting the physics of the player, play a sound, and reward the player.
I simply keep an array of these handlers, and search it every time two objects collide. The response function will reside outside both Barrel:: and Player:: objects. The downside is that it does need to know about both Barrel and Player, and thus will typically include the headers for both.
(*) Alternatively, you could always sort A and B, so you know whether to look for A,B or B,A.