title: c++ Parameters not passed into operator overload<
body: <p>When creating an operator overload for a class "State", the operator that i've overloaded does not have any member variables initialized. </p>
  
  <pre><code>    bool operator&lt;(const State m)const  
      {
         return (mDist &lt; m.mDist);
      }
  </code></pre>
  
  <p>When adding a state into a priority queue which calls this operator, the value for mDist is not initialized</p>
  
  <p>This is the code that begins the process </p>
  
  <pre><code>int row=0;
  int col=0;
  current.getBlank(row, col); // gets position of 0 in 3x3 int array
  
  
  if (row &gt; 0)
  {   
      //creates a new state with current 3x3 array and postion of 0 as member variables
      State u(current, row, col); 
      u.swapUp();           // swaps 0 with position above it
      //n.findMDist(goal);  //calculates Manhattan distance from goal state
      nextMoves.push(u);    //push into queue
  }
  </code></pre>
  
  <p>Any advice on what i should check that may cause the values to mot be passed to the operator overload?</p>
  
  <p>Edit : </p>
  
  <p>This is my state class. </p>
  
  <pre><code>#pragma once
  #ifndef STATE_H_
  #define STATE_H_
  #include&lt;iostream&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  
  const int SIZE = 3;
  
  class State
  {
  private:
      int board[SIZE][SIZE];
      int blankRow;
      int blankCol;
      State *parent;
      State *goal;
  
  public:
      State() 
      {
          int counter = 0;
          for (int i = 0; i &lt; SIZE; i++)
              for (int j = 0; j &lt; SIZE; j++)
              {
                  setValue(i, j, counter);
                  counter++;
              }
          int mDist = 0;
      }
  
      State(const State&amp; s) 
      {
          for (int i = 0; i &lt; SIZE; i++)
              for (int j = 0; j &lt; SIZE; j++)
                  board[i][j] = s.getValue(i, j);
      }
      State(const State&amp; s, int r, int c, State *g) 
      {
          for (int i = 0; i &lt; SIZE; i++)
              for (int j = 0; j &lt; SIZE; j++)
                  board[i][j] = s.getValue(i, j);
          blankRow = r;
          blankCol = c;
          goal = g;
          findMDist(*goal);
      }
  
      //get
      int mDist;
  
  
      //find
      void findMDist(State Goal);
  
  
      bool operator&lt;( State m)const   
      {
          return (mDist &lt; m.mDist);
      }
  
  };
  
  #endif
  </code></pre>
  
  <p>This is where mDist is implemented  </p>
  
  <pre><code>void Game::next() {
  
  int row=0;
  int col=0;
  current.getBlank(row, col);
  
  
  if (row &gt; 0)
  {
      State u(current, row, col);
      u.swapUp();
      n.findMDist(goal);
      nextMoves.push(u);
  }
  if (row &lt; 2)
  {
      State d(current, row, col);
      d.swapDown();
      n.findMDist(goal);
      nextMoves.push(d);
  }
  if (col &lt; 2)
  {
      State n(current, row, col);
      n.swapRight();
      n.findMDist(goal);
      nextMoves.push(n);
  }
  if (col &gt; 0)
  {
      State n(current, row, col);
      n.swapLeft();
      n.findMDist(goal);
      nextMoves.push(n);
  }
  }
  </code></pre>