title: Rotate a 2D array in-place without using a new array - best C++ solution?
body: <p>One of my students asked me this kind of homework with C++ arrays. It seemed quite interesting for me, so, though I have solved this problem, I wanted to share my solution with you and know another variants and opinions. The problem is following:</p>
  
  <p><strong>Problem</strong>
  It is given a 2D dynamic quadratic matrix (array) A(nxn). It is required to rotate the array by 90 degree anticlockwise, that is to say, after rotation A[1,1] field should contain the value of A[1,n] and A[1,n] field should contain the value of A[n,n]. <strong>And also it is required that while solving this problem you should not use any other array.</strong></p>
  
  <p><strong>My solution</strong>
  I have told to the student to do the following (will represent steps schematically):<br>
  I have suggested to define a class which, as its member, will have the 2D array. And to define a operation which will return reference on <em>A[j,n+1-i]</em> element when the user will request <em>A[i,j]</em> one. In two words I have suggested to create a wrapper for the array, and manipulate by array through the wrapper.</p>