Algorithm to multiply two matrices
Well, first you should create your own class for matrices. Your current ad-hoc representation is inefficient and lacks abstraction.
Options include:


Row-major or column-major.
Restricted to specific dimensions / square matrices.
Using an array of pointers to rows/colums or explicit mapping of coordinates to ids.

Is there a reason you insist that the result-matrix should be square? Seems gratuitious.
There's no advantage to modifying the first input instead of returning a new matrix. So, make both arguments constant and return the result instead.
If you don't need an object any longer after copying it, might moving be more appropriate, as it's potentially more efficient and less likely to throw?