title: try to find the shortest path between two points in a (x,y) coordinate system in C++. Got 11db erro
body: <p>This is part of my homework which is to find the shortest path between two points in a x,y graph (the size of the graph is 640*340.). THE PATH SHOULD ONLY GO THROUGH THE POINTS WHERE (X,Y)VALUES ARE INTEGERS. I am new to C++, but the teacher told us we have code it in C++. My code is as follows:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;unordered_map&gt;
  #include &lt;utility&gt;
  #include &lt;array&gt;
  #include &lt;cmath&gt;
  
  using namespace std;
  
  class nodePoint {
  public:
  int x;
  int y; // the x, y cordinates of each point
  nodePoint * prevPostion; // a pointer towards the previous point in the path leading to it.
  int distance; // how many "points" away from the starting point.
  };
  
  
  
  void findshortest (nodePoint start,nodePoint end){
      for (int i=-1; i&lt;2; i++) {
          for (int j=-1; j&lt;2; j++) {
              nodePoint *nextNode=new nodePoint();
              nextNode-&gt;x=start.x+i;
              nextNode-&gt;y=start.y+i;// iterate all the neighboring points of the point.
              if (nextNode-&gt;x &lt;= 640 &amp;&amp; nextNode-&gt;y &lt;=360 &amp;&amp; nextNode-&gt;x &gt;=0 &amp;&amp;nextNode-&gt;y&gt;=0 )// check to see if the point is out of the bound
              {
                  if (nextNode-&gt;x==end.x &amp;&amp; nextNode-&gt;y==end.y) // the point is the ending points.
                  {
                      if (end.distance&gt;start.distance+1) {
                          end.prevPostion=&amp;start;
                          end.distance=start.distance+1;
                      }
                  }else{
                      findshortest(*nextNode, end);
              }
          }
       }
      }
  }
  
  
  
  int main()
  {
      nodePoint *one=new nodePoint();// "one" is the starting point
      one-&gt;x=1;
      one-&gt;y=2; //just for testing.
      one-&gt;distance=0;
      nodePoint *two=new nodePoint();// "two" is the end point
      two-&gt;x=3;
      two-&gt;y=4; // just for testing.
      two-&gt;distance=pow(two-&gt;distance, 10);//set the initial distance value of the end point. It should be a very big number, so that it will be replaced later.
  
      findshortest(*one, *two); //look for the shortest path using the function we just defined.
  
      nodePoint *printer=new nodePoint(); // set a node to iterate over the shortest path through the previous node.
      printer=two;
      while (two-&gt;prevPostion!=NULL) {
          printf("%d,%d",printer-&gt;x,printer-&gt;y); // print out the (x,y) value of each of the point on the path.
          printer=two-&gt;prevPostion;
      }
  
      return 0;
  }
  </code></pre>