Setting up a Box2D World (Noob Question)

I'm still trying to figure out how to work Box2D. For my program, say I have a player, enemies, weapons, etc.
Question 1: Where do b2Bodys fall in the picture? Should it be an IS-A or HAS-A relationship? I'm using Box2D mainly for collision and have objects moving all over the place. I need to figure out if objects collide and if so remove the Missile (Weapon) and update damage on the object hit.

Question 2: How do I process collision? I tried to read the manual but am a little bit confused. Do I make my game manager extend the ContactListener class or what? Plus I'm assuming I have to use filters to make sure the player's shots only affect the enemy and vice versa.

Question 3: How do I set constraints for my window? Should I make a few shapes on the outside and if objects hit the shapes they should be destroyed?

I think that's all for now, I might have more later. I really wish there were better tutorials for Box2D; the learning curve for this library is pretty steep. Most tutorials I find are for Actionscript. There should also be a Help subforum.
1) Has-a, though this is game programming and not really related to box2d.
2) It's usually easiest to make a new class extending b2ContactListener that serves no purpose other than tracking events.
3) Sure

The learning curve is not great, but it's hard to improve on. Why not contribute to the wiki if you have anything particular in mind that annoyed you.
BorisTheBrave wrote:
1) Has-a, though this is game programming and not really related to box2d.

Agreed: I tend to live by the rule that if you have to think about that question for more than a second, it's a Has-A relationship that you're looking at.

Inheritance is a terrible, nasty, evil beast, and you should never ever use it, except when it's exactly the thing that you should use.
Pretty much. Though occasionally I get fed up of this advice: if an object has many children, then clearly it has-a list of children, but aliasing every single stl method to work with your object gets ridiculous compared with inheritance.
But in this case it's more pragmatic. Bodies are allocated by Box2D, so it is not possible to extend them.
Yeah I figured that out when I found the GetUserData and SetUserData functions. made a little more sense.

but in my current game I can't delete bodies. If I delete a body an exception gets thrown (debugger traces it to b2Joint or something, even though my bodies don't have joints...just a shape each (I'm doing a very simple test). Also if I try to run it in debug mode, another exception is called (something in b2Pair or something).

What's also weird is when I do a simple test with the player shooting a laser when they hit spacebar, I delete the Weapon after it leaves the screen, and when I print out the pointer to the b2Body that the Weapon has, it's always the same. I don't delete the body (as I can't), but when I print the body before I delete the Weapon, the same address keeps printing (if I shoot one at a time). If I shoot multiple shots before one gets deleted, the address may change, but eventually reverts to one single address.

I guess first question, when should (can) I delete bodies?
You cannot delete bodies, or otherwise modify the world during events. But to be honest, it sounds more like you've just screwed up your own code, if you are getting pointer inconsistencies.
well I meant destroy via b2World->DestroyBody();

I figured out that part of my problems was in the ContactListener where I think I modified a body directly from the ContactListener class (I call a function that caused a body to sleep...that would break it wouldn't it?)

I got a little bit confused on the wiki until I actually took the whole source code file and examined it.

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