You're passing your matrices by value. This results in a copy being made when the function is entered; all operations take place on those copies, not on the original matrices.
You need to pass them by reference
QVector<QVector<int> >& matrix, QVector<QVector<int> >& result
QVector<QVector<int> >& matrix, QVector<QVector<int> >& result
To copy to clipboard, switch view to plain text mode
(Note the ampersands.)
The C-style version works because you are effectively doing the same thing. You're passing in a pointer to the external arrays, not a copy. Pass-by-reference works exactly the same way, while providing some syntactic sugar by eliminating the need to dereference the arguments.
Bookmarks