title: Using a class function inside another function in the same class in C++
body: <p>How would I go about using the function swap inside the class function rotate matrix? I haven't been able to find any answers to this.  </p>
  
  <pre><code>void matrix::swap(int&amp; a, int&amp; b)
  {
      int temp = a;
      a = b;
      b = temp;
  }
  
  void matrix::rotateMatrix()
  {
  
      int n = m_matrixSize;
      int level = 0;
      int last = n-1;
      int numOfLevels = n/2 ;
  
      while(level &lt; numOfLevels)
      {
          for(int i = level;i &lt; last; i++)
          {
              swap(matrix[level][i], matrix[i] [last]);
              swap(matrix[level][i], matrix[last][last - i + level]);
              swap(matrix[level][i], matrix[ last - i + level][level]);
          }//end for
          ++level;
          --last;
       }//end while
  }//end rotateMatrix
  </code></pre>