title: Find what bodies are colliding in Box2D using C++
body: <p>I have a basic class for detecting collisions but I can't figure out how to see what bodies are colliding to trigger the appropriate event. Lets say I have a pong game and in it a ballBody and topwallBody. How would I figure out if these are colliding or not. Here is the class I'm using just to give you an idea.</p>
  
  <pre><code>class MyListener : public b2ContactListener
  {
      void BeginContact(b2Contact* contact)
      {
          b2Fixture* fixtureA = contact-&gt;GetFixtureA();
          b2Fixture* fixtureB = contact-&gt;GetFixtureB();
          b2Body* body1 = fixtureA-&gt;GetBody();
          b2Body* body2 = fixtureB-&gt;GetBody();
          cout &lt;&lt; "started";
      }
      void EndContact(b2Contact* contact)
      {
          cout &lt;&lt; "ended\n";
      }
  };
  MyListener listener;
  world.SetContactListener(&amp;listener);
  </code></pre>
  
  <p>It looks like I can get the bodies in the pointers but I have no idea how to compare them to other bodies.</p>